问题
I've been struggling with this for a while and have not found a solution.
I'm resizing a UIWebView
using animations through beginAnimations:
and commitAnimations
. All goes well, except for when the resizing tries to make the UIWebView
larger.
Let me make this clearer. Suppose the current frame of my UIWebView
is (0, 0, 320, 300)
.
Then, I try to resize it to (0, 0, 320, 340)
by using:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[self.webView setFrame:(CGRectMake(webView.frame.origin.x, webView.frame.origin.y, webView.frame.size.width, 340))];
[UIView commitAnimations];
By doing that, I expect the UIWebView
to come down 40 pixels, but it actually goes up a little bit (around 10 - 20 pixels) and only AFTER THAT it comes down to the desired position (so it ends up coming down around 50 - 60 pixels, actually).
Does anyone know how to solve that? What I want to do is have the bottom of my UIWebView
go down when the method is called, so if there are any other options for accomplishing it, I would be happy to try.
Thanks a lot.
回答1:
Instead of animating the frame of the UIWebView, you should try animating the bounds alone, or perhaps the bounds and center together. e.g. expand the height by 40 while simultaneously moving the center down by 20.
来源:https://stackoverflow.com/questions/3604812/issue-when-resizing-uiwebview-using-animation