Nico Reese
Nico Reese

Reputation: 261

Replicate iOS 7 homescreen animation

I'd like to replicate the iOS 7 homescreen animation. Mostly I'm interested in zooming in the scrollview to a specific point (top left if the icon is there, middle, or top right, etc)

http://www.youtube.com/watch?v=qBL8eQmQaVU

I thought I could use CGAffineTransformMakeScale but I couldn't figure out a way to scale it to a specific point. Any ideas?

Upvotes: 2

Views: 488

Answers (2)

Hemant Singh Rathore
Hemant Singh Rathore

Reputation: 2139

You can use this source code which replicates most functionality of iOS home screen.

Upvotes: 0

James Campbell
James Campbell

Reputation: 3591

You could just use Animation blocks? During the animation you could render a UIImage with the contents of the Scrollview via

UIGraphicsBeginImageContext(scrollView.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[scrollView.layer renderInContext:context];
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

You would put this image in the scrollview as a image view (With the image view's content mode set to resize to fit) overlaying the existing contents and make the image view is the same size as the scrollview at all times. Making it look like the whole scroll view is resizing.

Here is the animation block code.

Zoom Out

    scrollView.frame = icon.frame


    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationDelay:1.0];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

    scrollview.frame = window.frame;

    [UIView commitAnimations];

Zoom In

scrollView.frame = window.frame


    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationDelay:1.0];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

    scrollview.frame = icon.frame;

    [UIView commitAnimations];

Upvotes: 2

Related Questions