autoresizingMask

在 UIView 中有一个autoresizingMask的属性,它对应的是一个枚举的值(如下),属性的意思就是自动调整子控件与父控件中间的位置,宽高。


1

2

3

4

5

6

7

8

9

enum {

   UIViewAutoresizingNone                 = 0,

   UIViewAutoresizingFlexibleLeftMargin   = 1 << 0,

   UIViewAutoresizingFlexibleWidth        = 1 << 1,

   UIViewAutoresizingFlexibleRightMargin  = 1 << 2,

   UIViewAutoresizingFlexibleTopMargin    = 1 << 3,

   UIViewAutoresizingFlexibleHeight       = 1 << 4,

   UIViewAutoresizingFlexibleBottomMargin = 1 << 5

};

UIViewAutoresizingNone就是不自动调整。
UIViewAutoresizingFlexibleLeftMargin 自动调整与superView左边的距离,保证与superView右边的距离不变。
UIViewAutoresizingFlexibleRightMargin 自动调整与superView的右边距离,保证与superView左边的距离不变。
UIViewAutoresizingFlexibleTopMargin 自动调整与superView顶部的距离,保证与superView底部的距离不变。
UIViewAutoresizingFlexibleBottomMargin 自动调整与superView底部的距离,也就是说,与superView顶部的距离不变。
UIViewAutoresizingFlexibleWidth 自动调整自己的宽度,保证与superView左边和右边的距离不变。
UIViewAutoresizingFlexibleHeight 自动调整自己的高度,保证与superView顶部和底部的距离不变。
UIViewAutoresizingFlexibleLeftMargin  |UIViewAutoresizingFlexibleRightMargin 自动调整与superView左边的距离,保证与左边的距离和右边的距离和原来距左边和右边的距离的比例不变。比如原来距离为20,30,调整后的距离应为68,102,即68/20=102/30。

其它的组合类似。

时间: 2024-07-30 19:47:52

autoresizingMask的相关文章

iOS8 UIView之autoresizingMask 的使用

UIView的autoresizingMask属性 是用来适应父视图的变化(根据父视图的变化进而调整自身Frame属性). @property(nonatomic) BOOL autoresizesSubviews; // default is YES. if set, subviews are adjusted according to their autoresizingMask if self.bounds changes @property(nonatomic) UIViewAutore

xib中autoresizingMask属性失效问题

在ios的开发中,遇到UIView的排版问题,自然少不了layoutSubviews 这个函数与autoresizingMask这个属性. 在superview的autoresizesSubviews为Yes的时候,会根据subview的autoresizingMask类型进行自动排版,autoresizingMask可选的属性有 UIViewAutoresizingNone                 = 0, UIViewAutoresizingFlexibleLeftMargin  

iOS开发 autoResizingMask使用

autoResizingMask 是UIView的一个属性,在一些简单的布局中,使用autoResizingMask,可以实现子控件相对于父控件的自动布局. autoResizingMask 是UIViewAutoresizing 类型的,其定义为: @property(nonatomic) UIViewAutoresizing autoresizingMask; // simple resize. default is UIViewAutoresizingNone UIViewAutoresi

有关autoresizingMask属性遇到的一个小问题

前言:在讲述这个小问题之前,我们有必要先了解一下UIViewAutoresizing的有关属性概念和使用详解. 参考:自动布局之autoresizingMask使用详解(Storyboard&Code)     现在已经不像以前那样只有一个尺寸,现在最少的iPhone开 发需要最少需要适配三个尺寸.因此以前我们可以使用硬坐标去设定各个控件的位置,但是现在的话已经不可以了,我们需要去做适配,也许你说可以使用两套UI 或两套以上的UI,但那样不高效也不符合设计.iOS有两大自动布局利器:autore

UIView的autoresizingMask属性的使用

在iOS应用的开发过程中,经常会使用,setFrame的方式对UIView进行布局, 经常会使用计算的方式,如self.view.bounds.size.height - 20-44- Heignt等来计算Y的相对位置 我们知道上边的数字 20是status bar的高度,44是navigationBar的高度. 这样的写法没有什么错误,但是不利于代码的复用,比如一个ViewController在创建的时候,有可能有navigationController,也可能没有navigationCont

关于UIView的autoresizingMask属性的研究

在 UIView 中有一个autoresizingMask的属性,它对应的是一个枚举的值(如下),属性的意思就是自动调整子控件与父控件中间的位置,宽高. UIViewAutoresizingNone就是不自动调整.UIViewAutoresizingFlexibleLeftMargin 自动调整与superView左边的距离,保证与superView右边的距离不变.UIViewAutoresizingFlexibleRightMargin 自动调整与superView的右边距离,保证与super

@property(nonatomic) UIViewAutoresizing autoresizingMask;

在 UIView 中有一个autoresizingMask的属性,它对应的是一个枚举的值(如下),属性的意思就是自动调整子控件与父控件中间的位置,宽高. 1 2 3 4 5 6 7 8 9 enum {    UIViewAutoresizingNone                 = 0,    UIViewAutoresizingFlexibleLeftMargin   = 1 << 0,    UIViewAutoresizingFlexibleWidth        = 1 &l

关于UIView的autoresizingMask属性的研究【转】

在 UIView 中有一个autoresizingMask的属性,它对应的是一个枚举的值(如下),属性的意思就是自动调整子控件与父控件中间的位置,宽高. 1 2 3 4 5 6 7 8 9 enum {    UIViewAutoresizingNone                 = 0,    UIViewAutoresizingFlexibleLeftMargin   = 1 << 0,    UIViewAutoresizingFlexibleWidth        = 1 &l

自动布局之autoresizingMask使用详解(Storyboard&amp;Code)

现在已经不像以前那样只有一个尺寸,现在最少的iPhone开发需要最少需要适配三个尺寸.因此以前我们可以使用硬坐标去设定各个控件的位置,但是现在的话已经不可以了,我们需要去做适配,也许你说可以使用两套UI或两套以上的UI,但那样不高效也不符合设计.iOS有两大自动布局利器:autoresizing 和 autolayout(autolayout是IOS6以后新增).autoresizing是UIView的属性,一直存在,使用也比较简单,但是没有autolayout那样强大.如果你的界面比较简单,要