保持 UIButton 在屏幕上固定
我在 UIWebView 之上有一个 UIButton。 UIButton 应该看起来像是网页原生的。然而,当我放大 UIWebView 时,按钮随之而来,显然看起来不合适。有没有办法保持按钮相对于 UIWebView 的位置而不是其在屏幕上的位置?
感谢您的帮助!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定我是否理解你的问题,但这里是:
你可能有一个像这样的视图层次结构
也就是说,您的按钮已作为子视图添加到 UIWebView 中。由于 UIWebView 也是 UIScrollView,因此您可以获得观察到的行为。要修复此问题,请将按钮设置为同级按钮,而不是子按钮
如果添加在 UIWebView 之后,它仍然会绘制在你的 UIWebView 前面。
Not sure I've understood your problem, but here goes:
You've likely a view hierarchy like this:
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:
It will still be drawn in front of your UIWebView if it was added after the UIWebView.