为 UISubView 中的子视图获取可用空间
我喜欢在 Base UIView 中添加短语(图标和文本以及图像视图和标签)作为子视图。这些短语随机显示和定位。
是否有一种易于使用的方法来获取 UIView 上子视图的可用空间、区域或可能的区域(按大小)?
谢谢
I like to add phrases (icon and text also imageview and label) as subviews in a Base UIView. The phrases are displayed randomly and positioned.
Is there an easy to use method to get the free space, region, or possible region (by size) for subviews on a UIView?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有任何内置功能可以做到这一点。您必须根据
superview
的subviews
数组自行计算。There's nothing built-in that does that. You'd have to calculate it yourself from the
subviews
array of thesuperview
.您可以使用 CGRectUnion(CGRect r1, CGRect r2)
如果超过两个子视图,请使用循环 &调用这个函数
You can use
CGRectUnion(CGRect r1, CGRect r2)
if more than two subviews, use loop & call this function