iPhone: How to set animation style for UIView?
Im using the following code to animate the page.
[UIView a animateWithDuration:0.3
animations:^{
text.alpha=0;
开发者_开发知识库 } completion:^(BOOL finished) {
//some code
}];
Now I want to change the view using some animation style (curl ripple etc). How do I do it?
[UIView transitionWithView:superView duration:1.0
options:UIViewAnimationOptionTransitionCurlUp
animations:^{
[self.view removeFromSuperview];
[superView addSubview:newView];
}
completion:NULL];
You might need to set animation transition:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration: 1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:NO];
//your code
[UIView commitAnimations];
//try uiview directly or change uiview as your view in ui viewcontroller
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self cache:YES];
[UIView commitAnimations];
I've correct it to work in alternative to superview:
[UIView transitionWithView:self.parentViewController.view duration:1.0
options:UIViewAnimationOptionTransitionCurlUp
animations:^{
[self.view removeFromSuperview];
[self.parentViewController.view addSubview:self.newVC.view];
}
completion:NULL];
精彩评论