Challenge: Dynamic Layer Content

Give boxLayer a delegate to draw its content. When the layer is near the top of the screen, draw the Hypno.png image to the layer in the delegate method with full opacity. As the layer approaches the bottom of the screen, draw the image more transparently.

This is a very difficult challenge, so you can have three hints:

  1. The delegate of boxLayer cannot be HypnosisView.
  2. You must send setNeedsDisplay to the layer every time it changes position.
  3. To set the opacity of drawing in a context, use the function CGContextSetAlpha.

Happy coding!

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

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