简体   繁体   English

如何以编程方式设置UIView的自动调整大小蒙版?

[英]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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM