为 UISubView 中的子视图获取可用空间

发布于 2024-12-29 15:35:40 字数 130 浏览 1 评论 0原文

我喜欢在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

对不⑦ 2025-01-05 15:35:40

没有任何内置功能可以做到这一点。您必须根据superviewsubviews 数组自行计算。

There's nothing built-in that does that. You'd have to calculate it yourself from the subviews array of the superview.

镜花水月 2025-01-05 15:35:40

您可以使用 CGRectUnion(CGRect r1, CGRect r2)
如果超过两个子视图,请使用循环 &调用这个函数

You can use CGRectUnion(CGRect r1, CGRect r2)
if more than two subviews, use loop & call this function

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文