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.

Solution

Solution - iOS Tutorial

From the course: Advanced iOS App Development: Core Animation

Start my 1-month free trial

Solution

(sweeping music) - [Instructor] All right, let's start off by creating a new function, and we're going to call this func createTextLayer. Now, inside here, we're just going to create a new variable, called titleLayer, and this is going to be of type CATextLayer. Just like with the replicator, we need to specify a frame and set up its properties. We'll say titleLayer.frame = a new CGRect, and we're going to have this be x at the 0 position, y is 100, width is going to be AnimationHelper.screenBounds.width, and height of 100. This is going to fill most of the top part of the screen. Now we can also set the titleLayer.string property, I'm just going to give this a string "Dashboard." Finally, I want the text to be centered, so I'm going to say titleLayer.alignmentMode = "center." Now that's left is to add this new textLayer to the main view and run the app to make sure this looks right. Can't forget to go up to viewDidAppear and underneath our createReplicatorLayer, just call…

Contents