Study autoresizing mask

来源:互联网 发布:tower git mac 使用 编辑:程序博客网 时间:2024/05/10 15:25

Reference website

autoresizing masks defines how a view's frame changes when its superview's frame changes.

enum {

   UIViewAutoresizingNone                 = 0,
   UIViewAutoresizingFlexibleLeftMargin   = 1 << 0,
   UIViewAutoresizingFlexibleWidth        = 1 << 1,
   UIViewAutoresizingFlexibleRightMargin  = 1 << 2,
   UIViewAutoresizingFlexibleTopMargin    = 1 << 3,
   UIViewAutoresizingFlexibleHeight       = 1 << 4,
   UIViewAutoresizingFlexibleBottomMargin = 1 << 5
};

typedef NSUInteger UIViewAutoresizing;

UIViewAutoresizingFlexibleWidth means that the view's width will expand and shrink when its superview's width expands and shrinks.

UIViewAutoresizingFlexibleHeight means the same things for height.

If there are no "struts"set, when the superview doubles in width, the view will doubles in width as well.

The strut settings are:

  • UIViewAutoresizingFlexibleRightMargin
  • UIViewAutoresizingFlexibleLeftMargin
  • UIViewAutoresizingFlexibleTopMargin
  • UIViewAutoresizingFlexibleBottomMargin
If  UIViewAutoresizingFlexibleRightMargin is NOT set, the right strut is turned on. This means that the space between the right side of your view and the right side of its superview will not change when the view expands. The same concept holds for all the other margins.

0 0
原创粉丝点击