(iphone) set subview's frame outside of superview's bound?

让人想犯罪 __ 提交于 2019-12-07 11:41:48

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/5407416/iphone-set-subviews-frame-outside-of-superviews-bound

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