Issue when resizing UIWebView using animation

喜夏-厌秋 提交于 2019-12-25 11:34:11

问题


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

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