[英]How to set UIView's autoresizing mask programmatically?
I have to set autoresizingMask programmatically for UIView. 我必须以编程方式为UIView设置autoresizingMask。
I don't know how to implement this. 我不知道该怎么实现。
这就是您需要设置的方式。
yourView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin;
To achieve what you have in that screen shot you need to do the opposite of what DrummerB suggests. 要实现该屏幕快照中的功能,您需要执行DrummerB建议的相反操作。 You want a fixed top margin and right margin so you make every other side flexible like so: 您需要固定的顶部边距和右侧边距,以便使其他面都具有灵活性,如下所示:
view.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin;
view.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin;
If you want to know the concept very clearly, 如果您想非常清楚地了解这个概念,
UIView's autoresizing mask programmatically UIView的自动调整大小蒙版以编程方式
View AutoResizingMask Constant 查看AutoResizingMask常数
UIView AutoResizingMask UIView AutoResizingMask
Autoresizing masks programmatically vs Interface Builder / xib / nib 以编程方式自动调整蒙版大小与Interface Builder / XIB / NIB
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.