开发者

Keeping UIButton Stationary on Screen

开发者 https://www.devze.com 2023-03-19 09:06 出处:网络
I have a UIButton on top of a UIWebView. The UIButton is supposed to look like it\'s native to the 开发者_如何学运维webpage. However, when I zoom in on the UIWebView, the button comes with it, obvious

I have a UIButton on top of a UIWebView. The UIButton is supposed to look like it's native to the 开发者_如何学运维webpage. However, when I zoom in on the UIWebView, the button comes with it, obviously looking out of place. Is there a way to keep the button's position relative to the UIWebView rather than its position on screen?

Thanks for any help!


Not sure I've understood your problem, but here goes:

You've likely a view hierarchy like this:

  • View
    • UIWebView
      • UIButton

That is, your button was added as subview to the UIWebView. Since the UIWebView is also a UIScrollView you get the behavior you've observed. To fix it, make the button a sibling, not a child:

  • View
    • UIWebView
    • UIButton

It will still be drawn in front of your UIWebView if it was added after the UIWebView.

0

精彩评论

暂无评论...
验证码 换一张
取 消