美文网首页
iOS自动布局之autoresizingMask

iOS自动布局之autoresizingMask

作者: 横渡 | 来源:发表于2016-03-15 17:42 被阅读87次

    autoresizing是UIView的属性,一直存在,使用也比较简单,但是没有autolayout那样强大。如果你的界面比较简单,要求的细节没有那么高,那么你完全可以使用autoresizing去进行自动布局。以下会针对autoresizing进行讨论。

    autoresizing使用前的解释

    typedef NS_OPTIONS(NSUInteger, UIViewAutoresizing) {
    UIViewAutoresizingNone                 = 0, // 不会随父视图的改变而改变
    UIViewAutoresizingFlexibleLeftMargin   = 1 << 0, //自动调整view与父视图左边距,以保证右边距不变
    UIViewAutoresizingFlexibleWidth        = 1 << 1, //自动调整view的宽度,保证左边距和右边距不变
    UIViewAutoresizingFlexibleRightMargin  = 1 << 2,
    UIViewAutoresizingFlexibleTopMargin    = 1 << 3,
    UIViewAutoresizingFlexibleHeight       = 1 << 4,
    UIViewAutoresizingFlexibleBottomMargin = 1 << 5
    };
    

    使用autoresizing进行界面适配注意事项

    • 必须所有控件都按照Iphone4(320, 480)为基础初始化一次,不然按比例缩放时会发生错误!
    • view的autoresizesSubviews属性为yes时(默认为yes),autoresizing才会生效。

    相关文章

      网友评论

          本文标题:iOS自动布局之autoresizingMask

          本文链接:https://www.haomeiwen.com/subject/vikqlttx.html