John S
John S

Reputation: 1737

Simulate push view animation inside UIView

I have a single UIView with some labels that display attributes from objects inside an array. I'm using gesture recognizers to change the current element in the array and hence the text in the labels. My question is how do I mimic a push animation without actually pushing a new view controller. Thanks for your help.

Upvotes: 0

Views: 2473

Answers (2)

Splendid
Splendid

Reputation: 1061

Thats simple way to use CGAffineTransformMakeTranslation to move any view from X axis to Y axis using UIViewAnimation. Before using this transition set your object frame to some x,y axis(0,0) and pass your x and y to move from.

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.4];
CGAffineTransform transform = CGAffineTransformMakeTranslation(x,y);

YOUR ViewOBJECT.transform=transform;


[UIView commitAnimations];

Upvotes: 0

Jakob W
Jakob W

Reputation: 3377

Have you tried to use the UIView class methods for animation? For example this could help:

+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations

In the animations block you could move one view out and another in.

Upvotes: 0

Related Questions