July Boulder iOS Meetup Recap

This past Tuesday iOS developers from across the metroplex gathered at Google's new digs in Boulder. The night started with some brief announcements from meetup leader Justin Shacklette who informed us that his first iPad game Jab-a-Face has finally made it into the app store. Congrats Justin!

Our guest speaker was Paul Franceus of Google, and his presentation was titled "Get Moving with Core Animation." I really enjoyed Paul's presentation, and he made it easy to see how powerful Core Animation is. Paul outlined that there are really two main ways to animate layers with Core Animation: implicit animations and explicit animations.

Implicit Animations

These animations take much less code to get working. Developers simply change the properties of layers and use [UIView commitAnimations] to trigger all the animations at once. The default duration for these animations is .25 seconds. Great for fading stuff in and out. Paul was praising Core Animation all night saying "it just figures it out." This definitely seems like the lazy man's way to simple animations.

view.center = CGPointMake(center.x + xOffset, center.y + yOffset);
CGRect newBounds = CGRectMake(0, 0, subviewSize_.width, 
     subviewSize_.height);
CGFloat scale = [GraphicsUtils scaleForSize:view.bounds.size 
     inRect:newBounds];
CGAffineTransform scaleAndRotate =
CGAffineTransformRotate(CGAffineTransformMakeScale(scale, scale), 
     angle * index + M_PI_2);
view.transform = scaleAndRotate;
[UIView commitAnimations];  

Explicit Animations

These animation give you more control. You start by declaring a CABasicAnimation object and then setting all the appropriate properties you want to manipulate. After you've created the animation object you then add the animation to the layer.

CABasicAnimation *wobble = [CABasicAnimation animationWithKeyPath:
    @"transform.rotation.z"];
wobble.timingFunction = [CAMediaTimingFunction 
    functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
wobble.duration = 0.1 + (rand() % 10) * 0.005;
wobble.repeatCount = HUGE_VALF;
wobble.autoreverses = YES;
wobble.fromValue = [NSNumber numberWithFloat:DEGREES_TO_RADIANS(5)];
wobble.toValue = [NSNumber numberWithFloat:-DEGREES_TO_RADIANS(5)];
[layer addAnimation:wobble forKey:@"transform.rotation.z"];

Paul discussed several fun aspects of Core Animation, but the one I liked the most was the idea of group animations. Grouped animations allow you to set up several animations on one layer and then trigger them at once.

He also discussed some of the performance issues he and his team encountered when they were making Google Books for the iPhone. He said that performance starts to suffer around 200+ layers on screen at once. Paul also said that performance issues can occur with multiple layers that have their opacity turned down. When asked how to tell the difference between Core Animation and Open GL animations, Paul showed us the page flip animation in Google books which is true 3D animation. Core animation only allows for 2.5D animation, which is really morphing a 2D object to make it appear like it has a third dimension.

Paul said that he and his team went to WWDC and they were very impressed with some of the new features in Core Animation for iOS 5. He refused to tell us what they were. :) Throughout the presentation he also made references to Core Animation being used in Lion, Apple's new version of OS X.

The code samples above were taken from his presentation. You can find the demo source code here.

Events Mobile

Read This Next