Skip to Content
Beginning iOS 5 Application Development
book

Beginning iOS 5 Application Development

by Wei-Meng Lee
January 2012
Beginner content levelBeginner
655 pages
16h 35m
English
Wrox
Content preview from Beginning iOS 5 Application Development

Animating the Visual Change

You may have noticed that as you move the slider toward the right, the animation slows and becomes choppy. To make the animation smoother, you can animate the visual changes by using one of the block-based animation methods. One such block-based animation method is the animateWithDuration:delay:options:animations:completion: class method of the UIView class:

[UIView animateWithDuration:slider.value
                      delay:0.0f
                    options:UIViewAnimationOptionAllowUserInteraction |
                            UIViewAnimationOptionCurveLinear
                 animations:^{
                     imageView.center = CGPointMake(imageView.center.x + delta.x,
                                                    imageView.center.y + delta.y);
                     }
                     completion:nil];

The preceding code performs the specified animations immediately using the UIViewAnimationOptionCurveLinear (constant speed) and UIViewAnimationOptionAllowUserInteraction (allows the user to interact with the views while they are being animated) animation options. This results in a much smoother animation.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering iOS 12 Programming - Third Edition

Mastering iOS 12 Programming - Third Edition

Donny Wals
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer

Publisher Resources

ISBN: 9781118144251Purchase book