Keeping UIButton Stationary on Screen
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
- UIWebView
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.
精彩评论