|
1 |
| - |
2 |
| - |
3 |
| -`EZYGradientView` is a different and unique take on creating gradients and gradients with blur on the iOS platform. The default `CAGradientLayer` implementation works just fine, but is confusing and gives different results than expected. From the documentation: |
4 |
| - |
5 |
| -> The start point corresponds to the first stop of the gradient. The point is defined in the unit coordinate space and is then mapped to the layer’s bounds rectangle when drawn. |
6 |
| -
|
7 |
| -It's not really clear what the mapped values for the start and end points will be. If we set the start x coordinate 0.2, it does not resolve to 0.2 of the view's width on the X-axis. |
8 |
| - |
9 |
| -This library attempts to create gradients intuitively. When you use `EZYGradientView`, you don't need to worry about Apple's default API. What you do need to concern yourself with is: |
10 |
| - |
11 |
| -* What your colors are |
12 |
| -* The angle of the gradient |
13 |
| -* The ratio in which the two colors are distributed; and finally... |
14 |
| -* The intensity with which the colors are dispersed |
15 |
| - |
16 |
| -`EZYGradientView` exposes five properties you can modify to customize your gradient. The view itself is `IBDesignable` and its properties `IBInspectable` which means you can customize your gradient in real time on an xib or storyboard. |
17 |
| - |
| 1 | + |
| 2 | + |
| 3 | +`EZYGradientView` is a different and unique take on creating gradients and gradients with blur on the iOS platform. The default `CAGradientLayer` implementation works just fine, but is confusing and gives different results than expected. From the documentation: |
| 4 | + |
| 5 | +> The start point corresponds to the first stop of the gradient. The point is defined in the unit coordinate space and is then mapped to the layer’s bounds rectangle when drawn. |
| 6 | +
|
| 7 | +It's not really clear what the mapped values for the start and end points will be. If we set the start x coordinate 0.2, it does not resolve to 0.2 of the view's width on the X-axis. |
| 8 | + |
| 9 | +This library attempts to create gradients intuitively. When you use `EZYGradientView`, you don't need to worry about Apple's default API. What you do need to concern yourself with is: |
| 10 | + |
| 11 | +* What your colors are |
| 12 | +* The angle of the gradient |
| 13 | +* The ratio in which the two colors are distributed; and finally... |
| 14 | +* The intensity with which the colors are dispersed |
| 15 | + |
| 16 | +`EZYGradientView` exposes five properties you can modify to customize your gradient. The view itself is `IBDesignable` and its properties `IBInspectable` which means you can customize your gradient in real time on an xib or storyboard. |
| 17 | + |
18 | 18 | # Pod Installation
|
19 | 19 |
|
20 | 20 | CocoaPods is the preferred way to install this library. Add this command to your `Podfile`:
|
21 | 21 |
|
22 | 22 | ```
|
23 |
| -pod 'EZYGradientView' |
24 |
| -``` |
25 |
| - |
26 |
| - |
27 |
| - |
28 |
| - |
29 |
| -###For [Objective C](https://github.com/shashankpali/EZYGradientView-ObjC) |
30 |
| - |
| 23 | +pod 'EZYGradientView', :git => 'https://github.com/Niphery/EZYGradientView' |
| 24 | +``` |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +###For [Objective C](https://github.com/shashankpali/EZYGradientView-ObjC) |
| 30 | + |
31 | 31 |
|
32 | 32 | # Direct Installation
|
33 | 33 |
|
34 | 34 | Download .zip file and extract it. There you will find the `EZYGradientView` folder, copy EZYGradientView.swift to your respective project.
|
35 | 35 |
|
36 |
| -# Integration Methods |
37 |
| - |
38 |
| -## Storyboard/Xib |
39 |
| - |
40 |
| -Just follow these simple steps and create a gradient inside your xib or storyboard! |
41 |
| - |
42 |
| - |
43 |
| -### Initial Step (Use this step if downloaded by pod) |
44 |
| - |
45 |
| -###### while assigning EZYGradientView to UIView on StoryBoard/Xib don't forget to select module |
46 |
| - |
47 |
| -| Step | Description | |
48 |
| -|-------------------------------|---------------------------------------------------| |
49 |
| -|  | | |
50 |
| -|  | It will reflect warning if module is not selected.| |
51 |
| - |
52 |
| -### Step 1 - Select colors |
53 |
| - |
54 |
| -| Step | Description | |
55 |
| -|-------------------------------|---------------| |
56 |
| -|  | | |
57 |
| -|  | | |
58 |
| - |
59 |
| -### Step 2 - Set gradient angle |
60 |
| - |
61 |
| -| Step | Description | |
62 |
| -|-------------------------------|----------------| |
63 |
| -|  | Default is 0º. | |
64 |
| -|  | At 45º. | |
65 |
| -|  | At 135º. | |
66 |
| - |
67 |
| -### Step 3 - Set color ratio |
68 |
| - |
69 |
| -| Step | Description | |
70 |
| -|-------------------------------|-----------------------------------------------------------------------------------------------| |
71 |
| -|  | Default is 0.5, that's why colors are equally divided. Valid range 0 to 1. | |
72 |
| -|  | At 0.1, the first color takes one-tenth of the view area. The rest is filled by the second. | |
73 |
| -|  | At 0.9, the first color takes nine-tenths of the view area. The rest is filled by the second. | |
74 |
| - |
75 |
| -### Step 4 - Set fade intensity |
76 |
| - |
77 |
| -| Step | Description | |
78 |
| -|-------------------------------|---------------------------------------------------------------------------------------------------| |
79 |
| -|  | Default is 0, that's why there is a sharp boundary where the two colors meet. Valid range 0 to 1. | |
80 |
| -|  | At 0.5, there is a much smoother transition between the two colors. | |
81 |
| -|  | At 1, the maximum transition smoothness is achieved. | |
82 |
| - |
83 |
| -### Step 5 - Set isBlur and blur opacity |
84 |
| -######(This feature is available for ios 8 and above) |
85 |
| - |
86 |
| - |
87 |
| -| Step | Description | |
88 |
| -|-------------------------------|---------------------------------------------------------------------------------------------------| |
89 |
| -|  | Default is 0, where the blur transparency is minimmum. Valid range 0 to 1. | |
90 |
| -|  | At 1.0, where the blur transparency is maximum.(The black spot is a label behind gradient view) | |
91 |
| -| Suggestion | Use this properties to design `navigationBar`, `tabBar`, `tableHeaderView` etc. | |
92 |
| - |
93 |
| -## Programmatic way |
94 |
| - |
95 |
| -```swift |
96 |
| -let gradientView = EZYGradientView() |
97 |
| - gradientView.frame = view.bounds |
98 |
| - gradientView.firstColor = UIColor(red: 0.5, green: 0.0, blue: 1.0, alpha: 1.0) |
99 |
| - gradientView.secondColor = UIColor(red: 0.4, green: 1.0, blue: 0.8, alpha: 1.0) |
100 |
| - gradientView.angleº = 185.0 |
101 |
| - gradientView.colorRatio = 0.5 |
102 |
| - gradientView.fadeIntensity = 1 |
103 |
| - gradientView.isBlur = true |
104 |
| - gradientView.blurOpacity = 0.5 |
105 |
| - |
106 |
| - view.insertSubview(gradientView, atIndex: 0) |
107 |
| -``` |
108 |
| - |
109 |
| -# To-do |
110 |
| - |
111 |
| -* Allow more than two colors to create gradients. |
112 |
| -* It may crash if blur properties used in lower version than ios 8. |
113 |
| -* Use CoreGraphics blur to replace `UIVisualEffectView`. |
114 |
| - |
115 |
| -# Thanks |
116 |
| - |
117 |
| -* To [Sudeep Jaiswal](https://github.com/sudeepjaiswal) for motivating and special thanks for the documentation and ideas. |
118 |
| - |
| 36 | +# Integration Methods |
| 37 | + |
| 38 | +## Storyboard/Xib |
| 39 | + |
| 40 | +Just follow these simple steps and create a gradient inside your xib or storyboard! |
| 41 | + |
| 42 | + |
| 43 | +### Initial Step (Use this step if downloaded by pod) |
| 44 | + |
| 45 | +###### while assigning EZYGradientView to UIView on StoryBoard/Xib don't forget to select module |
| 46 | + |
| 47 | +| Step | Description | |
| 48 | +|-------------------------------|---------------------------------------------------| |
| 49 | +|  | | |
| 50 | +|  | It will reflect warning if module is not selected.| |
| 51 | + |
| 52 | +### Step 1 - Select colors |
| 53 | + |
| 54 | +| Step | Description | |
| 55 | +|-------------------------------|---------------| |
| 56 | +|  | | |
| 57 | +|  | | |
| 58 | + |
| 59 | +### Step 2 - Set gradient angle |
| 60 | + |
| 61 | +| Step | Description | |
| 62 | +|-------------------------------|----------------| |
| 63 | +|  | Default is 0º. | |
| 64 | +|  | At 45º. | |
| 65 | +|  | At 135º. | |
| 66 | + |
| 67 | +### Step 3 - Set color ratio |
| 68 | + |
| 69 | +| Step | Description | |
| 70 | +|-------------------------------|-----------------------------------------------------------------------------------------------| |
| 71 | +|  | Default is 0.5, that's why colors are equally divided. Valid range 0 to 1. | |
| 72 | +|  | At 0.1, the first color takes one-tenth of the view area. The rest is filled by the second. | |
| 73 | +|  | At 0.9, the first color takes nine-tenths of the view area. The rest is filled by the second. | |
| 74 | + |
| 75 | +### Step 4 - Set fade intensity |
| 76 | + |
| 77 | +| Step | Description | |
| 78 | +|-------------------------------|---------------------------------------------------------------------------------------------------| |
| 79 | +|  | Default is 0, that's why there is a sharp boundary where the two colors meet. Valid range 0 to 1. | |
| 80 | +|  | At 0.5, there is a much smoother transition between the two colors. | |
| 81 | +|  | At 1, the maximum transition smoothness is achieved. | |
| 82 | + |
| 83 | +### Step 5 - Set isBlur and blur opacity |
| 84 | +######(This feature is available for ios 8 and above) |
| 85 | + |
| 86 | + |
| 87 | +| Step | Description | |
| 88 | +|-------------------------------|---------------------------------------------------------------------------------------------------| |
| 89 | +|  | Default is 0, where the blur transparency is minimmum. Valid range 0 to 1. | |
| 90 | +|  | At 1.0, where the blur transparency is maximum.(The black spot is a label behind gradient view) | |
| 91 | +| Suggestion | Use this properties to design `navigationBar`, `tabBar`, `tableHeaderView` etc. | |
| 92 | + |
| 93 | +## Programmatic way |
| 94 | + |
| 95 | +```swift |
| 96 | +let gradientView = EZYGradientView() |
| 97 | + gradientView.frame = view.bounds |
| 98 | + gradientView.firstColor = UIColor(red: 0.5, green: 0.0, blue: 1.0, alpha: 1.0) |
| 99 | + gradientView.secondColor = UIColor(red: 0.4, green: 1.0, blue: 0.8, alpha: 1.0) |
| 100 | + gradientView.angleº = 185.0 |
| 101 | + gradientView.colorRatio = 0.5 |
| 102 | + gradientView.fadeIntensity = 1 |
| 103 | + gradientView.isBlur = true |
| 104 | + gradientView.blurOpacity = 0.5 |
| 105 | + |
| 106 | + view.insertSubview(gradientView, at: 0) |
| 107 | +``` |
| 108 | + |
| 109 | +# To-do |
| 110 | + |
| 111 | +* Allow more than two colors to create gradients. |
| 112 | +* It may crash if blur properties used in lower version than ios 8. |
| 113 | +* Use CoreGraphics blur to replace `UIVisualEffectView`. |
| 114 | + |
| 115 | +# Thanks |
| 116 | + |
| 117 | +* To [Sudeep Jaiswal](https://github.com/sudeepjaiswal) for motivating and special thanks for the documentation and ideas. |
| 118 | + |
119 | 119 | # License
|
120 | 120 |
|
121 |
| -`EZYGradientView` is available under the MIT license. See the LICENSE file for more info. |
| 121 | +`EZYGradientView` is available under the MIT license. See the LICENSE file for more info. |
0 commit comments