1
votes

I'm working to get my apps configured for the new iPhone 5. So I started with investigating the auto-layout guide of cocao touch ([link][1]) and the WDC masterclasses.

But still one thing is unclear to me. How can I animate my views.

In my previous Apps I used the regular UIView animation like:

            [UIView  beginAnimations:nil context:NULL];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            [UIView setAnimationDuration:0.75];
            MyView.frame = CGRectMake(0,100, 100, 100);
            [UIView commitAnimations];

Or the CGAffineTransform methods.

Can someone tell me what the best workaround is when working with auto-layout, since I'm unable to refer to frames and don't make frame-declarations anymore? Settings timers and removing and adding constraints?

3

3 Answers

3
votes

The constraints are really not at all related to the animations.

However, you should use the up to date block based animation methods such as animateWithDuration:animations:.

0
votes

You should use

[MyView layoutIfNeeded];

in animation block.

0
votes

Yeah, when you use Auto-layout all the setFrame methods are removed. In your case if you want the View to move about certain number of pixels you can try moving the center of the view instead of setting the frame of the view and set the priority of the constraints around the view to low.