(iPhone)将子视图的框架设置在超级视图的边界之外?
我注意到我可以将子视图放置在超级视图的边界之外(部分或全部)。
我想知道这是否可以接受,因为这在通常的 iPhone 视图编程中似乎是不正常的。
谢谢。
I noticed that I can place subview outside of superview's bound (either partly or fully).
I wonder if that's acceptable, since it seems to be abnormal in usual iphone view programming.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
另请注意,在实现可访问性时,越界子视图会带来问题。
可访问性框架可以正常显示,但仅在触摸父级边界内选择所述框架的区域时才会出现。如果子视图完全超出父视图的边界,则只能通过打开 VoiceOver 的情况下侧滑来访问。仅当点击父级边界内的子视图时,在屏幕上触摸拖动才会选择一个视图。
Also note that out of bounds sub views pose a problem when implementing accessibility.
The accessibility frame gets displayed alright, but only appears when selecting an area of te said frame when touching inside the parent's bounds. If the sub view is completely outside the parent's bounds it is only accessible by side swiping with VoiceOver on. Touch dragging across the screen will only select a view when hiting said sub view within the parent's bounds.
这是可以接受的,有时甚至是常见的做法 - 例如,滚动视图或其他“复合”视图的自定义实现通常会将对象放置或移动到超级视图的边界之外。
您可能对 UIView 属性
clipsToBounds< /code>
,它将子视图绘制限制为仅限于超级视图的边界。
This is acceptable and sometimes even common practice - custom implementations of scroll views or other "composite" views, for example, commonly place or move objects outside the superview's bounds.
You may be interested in the UIView property
clipsToBounds
, which restricts subview drawing to only the bounds of the superview.