Make a Flip animation (or something similar) when I reload the content of my UIWebView

萝らか妹 提交于 2019-12-13 15:46:32

问题


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


回答1:


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];



回答2:


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.



来源:https://stackoverflow.com/questions/17636280/make-a-flip-animation-or-something-similar-when-i-reload-the-content-of-my-uiw

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!