From the course: Advanced iOS App Development: Core Animation
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Working with keyframe animations, part 2 - iOS Tutorial
From the course: Advanced iOS App Development: Core Animation
Working with keyframe animations, part 2
- Up until this point, we've only animated non-struct layer properties, like opacity, or position Y, which Core Animation makes pretty easy. However, to get our clock image to look like it's bouncing along the bottom of the screen, we'll have to animate its position, which means we'll be using CGPoint values, which are structs. So let's take a look at how we can handle this kind of animation. Make some room underneath the create keyframe color animation, and start a new function called bounceKeyframeAnimation. This is gonna return a CAKeyframeAnimation, and let's go ahead and just create our bounce animation here. CAKeyframeAnimation for keyPath, we'll say AnimationHelper.position. Now this doesn't actually exist yet, so let's go into our animation helper, and add ourselves a new animatable property. Say static var position, and the keyframe string for that is just position. Let's return bounce, and save. For starters, let's say bounce.duration = three seconds, we want this to be a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.