Reputation: 7398
I need to add a UIDatePicker
subview on a button click to my main view.
How can I add the view with animation such that the subview flips in from the top of the main view and on removing ,undergoes the reverse animation ? I know the subview can be added in a frame that is outside the visible area of the view and then moving it to visible area using CABasicAnimation
will be abetter choice. So need help regarding the animation block that I should use.
Thanks in advance
Upvotes: 0
Views: 585
Reputation: 20541
Try this bellow code... here if yourView default frame with origin y = -500 then try bellow code on any UIButton
click event.. also set frame which you want
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
CGRect frame = yourView.frame;
frame.origin.y = frame.origin.y + 500; // give any value for display yourView
yourView.frame = frame;
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:yourView cache:YES];
[UIView commitAnimations];
Upvotes: 2