Silver Challenge: Adding a Gradient Layer

You learned in this chapter that all UIView instances are backed by a CALayer. Every view hierarchy is backed by a corresponding layer hierarchy, and you can create and add sublayers just as you can create and add subviews.

Use a CAGradientLayer to add a gradient to the background of the view controller (Figure 3.27). You will want this layer to be positioned behind the labels. For this challenge, you will want to consult the documentation for both CALayer and its subtype CAGradientLayer.

Figure 3.27  Gradient layer

Gradient layer

Hint: To position the layer, you will want to set the layer’s frame to be the same as the bounds of the view controller’s view. Layers do not participate in Auto Layout in the same way that views do, so you will also need to update the layer’s frame in the view controller’s viewWillLayoutSubviews() method.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.159.195