From the course: Advanced iOS App Development: Core Animation

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

CALayerDelegate

CALayerDelegate - iOS Tutorial

From the course: Advanced iOS App Development: Core Animation

Start my 1-month free trial

CALayerDelegate

- [Instructor] Now that we have our custom action, there are a couple of ways we can pair it with our layer. First off, every layer has a property called actions, which is a dictionary that acts as a lookup table for all the layer's associated actions. Now, one way to get the action installed on a layer would be to add it as the key-value pair to that dictionary. You could also do something similar with a layer-style property; however both of these options feel a bit too hard coded for my liking, so we're going to use the layer delegate to handle this instead. Let's go back to the dashboard view controller and underneath our view controller file, let's add a little bit of room and extend our class. We'll say extension, dashboard view controller to adopt the CA layer delegate protocol. Now the method we want, we've already talked about this, is called action for layer. Let's go up to view will appear, and we're gonna set our gradient layer.delegate to Self, and now every time our layer…

Contents