相对于父视图的底部定位 UIView? [英] Position a UIView relative to the bottom of the parent view?

查看:30
本文介绍了相对于父视图的底部定位 UIView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 UIView 与父级底部对齐,以便框架的 Y 坐标相对于屏幕底部而不是顶部?

How can I align a UIView to the bottom of the parent so that the Y coordinate of the frame is relative to the bottom of the screen instead of the top?

这相当于在 HTML 中设置 .bottom 属性.

This would be the equivalent to setting the .bottom property in HTML.

这是因为我想确保无论父级的高度如何,我的视图始终位于窗口的底部.

This is because I want to make sure my view is always at the bottom of window regardless of the height of the parent.

推荐答案

一旦您通过设置视图的 frame 属性初始定位视图,调整其 autoresizingMask 以包含 <代码>UIViewAutoresizingFlexibleTopMargin.这将使其锚定在其父视图的底部.

Once you have initially positioned the view by setting its frame property, adjust its autoresizingMask to include UIViewAutoresizingFlexibleTopMargin. That will keep it anchored to the bottom of its superview.

这篇关于相对于父视图的底部定位 UIView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆