autoresizing代码实现

主要解决父子控件之间的布局关系:
/*
     Flexible 灵活的,自由的
    
     typedef NS_OPTIONS(NSUInteger, UIViewAutoresizing) {
     UIViewAutoresizingNone                 = 0,
     UIViewAutoresizingFlexibleLeftMargin   = 1 << 0,
//   左边是自由的,右边是固定的(与storyboard中相反)

     UIViewAutoresizingFlexibleWidth        = 1 << 1,
//   宽度是可拉伸的
    
     UIViewAutoresizingFlexibleRightMargin  = 1 << 2,
//    右边是自由的,左边是固定的(与storyboard中相反)

     UIViewAutoresizingFlexibleTopMargin    = 1 << 3,
//    顶部是自由的,底部是固定的(与storyboard中相反)

     UIViewAutoresizingFlexibleHeight       = 1 << 4,
//   高度是自由的(高度是可拉伸的)

     UIViewAutoresizingFlexibleBottomMargin = 1 << 5
//    底部是自由的,顶部是固定的(与storyboard中相反)
     };
    
    
     */
    //四周固定,内部自由
   redView.autoresizingMask =UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
 
    //四周自由,内部固定  redView.autoresizingMask=UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleBottomMargin;
   
    //四周自由,内部也自由   redView.autoresizingMask=UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleBottomMargin;
posted @ 2015-05-26 23:22  jsonxml  阅读(153)  评论(0编辑  收藏  举报