Reputation: 2997
In one of my project i'm using only a UIWebView. I need an animation (for example a flip) when I reload my webView with another content... Is it possible to create a flip animation (or something similar)? I must create a fake controller to get it? Solutions? Thanks
Upvotes: 2
Views: 675
Reputation: 8571
You can always do the +transitionWithView:duration:options:animations:completion:
method with the web view.
[UIView transitionWithView:self.webView duration:1.0 options:UIViewAnimationOptionTransitionFlipFromLeft | UIViewAnimationOptionAllowAnimatedContent animations:
^{
[self.webView loadHTMLString:@"<strong>Hello world</strong>" baseURL:nil];
} completion:^(BOOL finished)
{
}];
This method is basically a way of saying: "change the contents of this view, in animated fashion". So it takes an snapshot of the current state, performs the animation (be it a flip, curl, etc) and then inserts an snapshot of the new state.
But notice that I've used UIViewAnimationOptionAllowAnimatedContent
, this forces the animation to not use a snapshot for the new state of the view, because setting loadHTMLString
does not change the view immediately, so we need to force it to use the live context of the view instead of a snapshot.
The weather app in iOS (pre 7) uses a similar method for alternating between the current weather and the picker for other regions/options when clicking the "i" on the bottom.
Upvotes: 3
Reputation: 115
I think that you don't need to create a controller for that. You can simply add something like that:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.80];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:yourView cache:YES];
[UIView commitAnimations];
Upvotes: 2