UIWebView and Animation

2019-02-10 12:16发布

问题:

I am wondering if there was a way to animate the size and position of a UIWebView. If I do sth like this:

[UIView animateWithDuration:1.0 animations:^{
    self.frame = CGRectMake(20.0, 20.0, 80.0, 80.0);
}];

or

[UIView beginAnimations:@"zoomIn" context:nil];
[UIView setAnimationDuration:2.75]; 
[UIView setAnimationDelegate: self];

    self.frame = CGRectMake(20.0, 20.0, 80.0, 80.0);

[UIView commitAnimations];

while there is a grey box doing the animation, the content of the WebView instantly switches to the new size without animating. (the scalesPageToFit property is set to YES)

any suggestions on that?

回答1:

Haven't cracked the instant changing of the text width yet but you can get rid of the grey box by programmatically changing the background of the UIWebView to clearColor. Doesn't work if you do it through Interface Builder, for some reason.