autoresizingMask的用法

UIView中有个属性是autoresizingMask,该属性是用来控制控件的自适应。

 

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

 

UIViewAutoresizingNone:控件相对于父视图坐标值不变;

UIViewAutoresizingFlexibleWidth:控件的宽度随着父视图的宽度按比例改变;

例如:label宽度为100,屏幕的宽度为320。当屏幕宽度为480时,label宽度变为100*480/320

UIViewAutoresizingFlexibleHeight:与UIViewAutoresizingFlexibleWidth相同

UIViewAutoresizingFlexibleLeftMargin:到屏幕左边的距离随着父视图的宽度按比例改变;

例如:CGRectMake(50, 100, 200, 40)]; 当屏幕的宽度为320,x为50;当屏幕宽度为480时,labelx坐标变为 50*480/320。控件坐标变为 CGRectMake(75, 100, 200, 40)];

UIViewAutoresizingFlexibleRightMargin、UIViewAutoresizingFlexibleTopMargin、UIViewAutoresizingFlexibleBottomMargin与UIViewAutoresizingFlexibleLeftMargin类似

autoresizingMask的用法

上一篇:node学习---web项目部署到node服务端样式不生效的问题


下一篇:三思笔记