绘图 - 8

来源:互联网 发布:jquery获得表单数据 编辑:程序博客网 时间:2024/05/16 05:29

autoresizesSubviews  和  autoresizingMask : 

@property(nonatomic) BOOL               autoresizesSubviews; // default is YES. if set, subviews are adjusted according to their autoresizingMask if self.bounds changes@property(nonatomic) UIViewAutoresizing autoresizingMask;    // simple resize. default is UIViewAutoresizingNone

都是UI布局非常常见的两个属性和方法。

我们来看看具体:





这两个方法的大体意思就是子类会随着视图父类bounds的变动而自动调整。

而autoresingMask是一个枚举值:

typedef NS_OPTIONS(NSUInteger, UIViewAutoresizing) {    UIViewAutoresizingNone                 = 0,    UIViewAutoresizingFlexibleLeftMargin   = 1 << 0,    UIViewAutoresizingFlexibleWidth        = 1 << 1,    UIViewAutoresizingFlexibleRightMargin  = 1 << 2,    UIViewAutoresizingFlexibleTopMargin    = 1 << 3,    UIViewAutoresizingFlexibleHeight       = 1 << 4,    UIViewAutoresizingFlexibleBottomMargin = 1 << 5};

大体的解释:



在实际使用中也非常容易:

    containerView.autoresizesSubviews = YES;    containerView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin  |                                     UIViewAutoresizingFlexibleRightMargin |                                     UIViewAutoresizingFlexibleTopMargin   |                                     UIViewAutoresizingFlexibleBottomMargin;


参考:

http://www.cnblogs.com/GarveyCalvin/p/4165151.html


这里提一下。如果用纯粹的autolayout,会发现效果比这个好多了!!


0 0
原创粉丝点击