![World of tanks blitz 2.5](https://loka.nahovitsyn.com/148.jpg)
![color ui text view color border xcode cg color color ui text view color border xcode cg color](http://pessoal.org/blog/wp-content/uploads/2009/02/standard.png)
- #Color ui text view color border xcode cg color update#
- #Color ui text view color border xcode cg color code#
Run the app and…whoa!? This isn’t what we want at all. Now, instead of adding our gradient as a sublayer we will set it as a mask: = gradient Go into Main.storyboard and add a UILabel filling the view and give it placeholder text of your choice. To see a fade, we first need to add some content.
![color ui text view color border xcode cg color color ui text view color border xcode cg color](https://venturebeat.com/wp-content/uploads/2020/03/microkingdoms2.jpg)
For the colors, whatever we want visible we need to set to a color (I’ll use black) and anything we want hidden we need to set it to a clear color. Now to take this gradient and use it to fade out content, we need to set it as the mask for our view’s layer. There is a lot more that you can do with CAGradientLayer and better ways of handling the rotation animation, but for our purposes this is all we need.
#Color ui text view color border xcode cg color code#
A quick way of doing this is to hold a reference to the gradient layer by making it a property of the ViewController and set the layer’s frame again whenever it lays out subviews, changing our ViewController code to look like this:
#Color ui text view color border xcode cg color update#
To make sure that our gradient is updated when the view changes, we need to update its frame when the view’s frame changes.
![color ui text view color border xcode cg color color ui text view color border xcode cg color](https://4.bp.blogspot.com/-DJiFyIyPRKc/UMf_yXPxyoI/AAAAAAAACjA/IGOMheiLAiA/s400/iOS%2BUILabel%2BProject.png)
One gotcha of working with layers is that if you rotate the device, you’ll see that the layer does not rotate with the view. For these locations, the gradient transitions from red to purple from the top of the view (0) to 10% down the view, then from purple to purple, which gives us the long solid purple color, and then the bottom 10% of the view changes from purple to blue. So to make a view that is mostly purple that transitions into red at the top and blue at the bottom, we would change the code colors to: lors = Īnd then add the following line: gradient.locations = Įach location corresponds to one of the colors. These are values between 0 (the top of the view) and 1 (the bottom of the view) and must be increasing in value. CAGradientLayer has a locations property that you can set to change the distribution of the colors. You can add any number of colors to the gradient, which are evenly spaced by default, but this can be changed as well. Run the app and you should see a red to blue vertical gradient covering the whole view.
![World of tanks blitz 2.5](https://loka.nahovitsyn.com/148.jpg)