autoresizingMask
本文为大地瓜原创,欢迎知识共享,转载请注明出处。
虽然你不注明出处我也没什么精力和你计较。
作者微信号:christgreenlaw
用于描述:当superview的bounds改变的时候,接收者如何resize自身。
是一个bit mask
当view的边界改变时,view自动根据其subview的autoresizeMask
来resize其subview。可以用C的比特OR操作符
对UIViewAutoresizing中所描述的常量进行结合,声明一份mask值。这样你可以指明view的哪些dimension应该相对于superview进行grow还是shrink。这个值默认是UIViewAutoresizingNone
,也就是说这个view不应该被resize。
When more than one option along the same axis is set, the default behavior is to distribute the size difference proportionally among the flexible portions. The larger the flexible portion, relative to the other flexible portions, the more it is likely to grow. For example, suppose this property includes the UIViewAutoresizingFlexibleWidth
and UIViewAutoresizingFlexibleRightMargin
constants but does not include the UIViewAutoresizingFlexibleLeftMargin
constant, thus indicating that the width of the view’s left margin is fixed but that the view’s width and right margin may change. Thus, the view appears anchored to the left side of its superview while both the view width and the gap to the right of the view increase.
If the autoresizing behaviors do not offer the precise layout that you need for your views, you can use a custom container view and override its layoutSubviews
method to position your subviews more precisely.
【autoresizingMask】如果autoresizing的行为没能提供你想要的样式,你可以自定义一个container view,重写其layoutSubviews
方法来准确地放置你的subview。
推荐阅读
- 为什么你的路演总会超时()
- 知识
- 财商智慧课(六)
- 低头思故乡——只是因为睡不着
- 华为旁!大社区、地铁新盘,佳兆业城市广场五期!
- 吃了早餐,反而容易饿(为什么?)
- 你有婚内虐待行为吗()
- Android中的AES加密-下
- ?【段子图】内裤为啥湿呢(想想好邪恶啊...)
- 孩子行为背后的秘密(2)胡老师讲座感悟