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

enum {
   UIViewAutoresizingNone                 = 0,
   UIViewAutoresizingFlexibleLeftMargin   = 1 << 0,
   UIViewAutoresizingFlexibleWidth        = 1 << 1,
   UIViewAutoresizingFlexibleRightMargin  = 1 << 2,
   UIViewAutoresizingFlexibleTopMargin    = 1 << 3,
   UIViewAutoresizingFlexibleHeight       = 1 << 4,
   UIViewAutoresizingFlexibleBottomMargin = 1 << 5
};
typedef NSUInteger UIViewAutoresizing;

分别解释以上意思。

UIViewAutoresizingNone就是不自动调整。

UIViewAutoresizingFlexibleLeftMargin就是自动调整与superView左边的距离,也就是说,与superView右边的距离不变。

UIViewAutoresizingFlexibleRightMargin就是自动调整与superView的右边距离,也就是说,与superView左边的距离不变。

UIViewAutoresizingFlexibleTopMargin

UIViewAutoresizingFlexibleBottomMargin

UIViewAutoresizingFlexibleWidth

UIViewAutoresizingFlexibleHeight

以上就不多解释了,参照上面的。

也可以多个枚举同时设置。如下:

subView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin  |UIViewAutoresizingFlexibleRightMargin;

如果有多个,就用“|”关联。

还有一个属性就是autoresizesSubviews,此属性的意思就是,是否可以让其subviews自动进行调整,默认状态是YES,就是允许,如果设置成NO,那么subView的autoresizingMask属性失效。

关于ios的控件的AutoresizingMask属性

setAutoresizingMask控件的自适应

UIViewAutoresizingNone                 = 0,

UIViewAutoresizingFlexibleLeftMargin   = 1 << 0,

UIViewAutoresizingFlexibleWidth        = 1 << 1,

UIViewAutoresizingFlexibleRightMargin  = 1 << 2,

UIViewAutoresizingFlexibleTopMargin    = 1 << 3,

UIViewAutoresizingFlexibleHeight       = 1 << 4,

UIViewAutoresizingFlexibleBottomMargin = 1 << 5

UIViewAutoresizingNone

UILabel*    label = [[UILabel alloc] initWithFrame:CGRectMake(50, 100, 200, 40)];

[label setAutoresizingMask: UIViewAutoresizingNone];  控件相对于俯视图坐标值不变

CGRectMake(50, 100, 200, 40)
 
UIViewAutoresizingFlexibleWidth:控件的宽度随着父视图的宽度按比例改变    例如
 
label宽度为 100     屏幕的宽度为320          当屏幕宽度为480时      label宽度  变为  100*480/320
同理  
UIViewAutoresizingFlexibleHeight相同
 
 
UIViewAutoresizingFlexibleLeftMargin  到屏幕左边的距离随着父视图的宽度按比例改变  
 
例如    
CGRectMake(50, 100, 200, 40)];   
50     屏幕的宽度为320          当屏幕宽度为480时      label宽度  变为  50*480/320
控件变为    
CGRectMake(75, 100, 200, 40)];  
 
UIViewAutoresizingFlexibleRightMargin
UIViewAutoresizingFlexibleTopMargin
UIViewAutoresizingFlexibleBottomMargin

ios的AutoresizingMask【转】的更多相关文章

  1. iOS开发 autoResizingMask使用

    autoResizingMask 是UIView的一个属性,在一些简单的布局中,使用autoResizingMask,可以实现子控件相对于父控件的自动布局. autoResizingMask 是UIV ...

  2. IOS - 控件的AutoresizingMask属性

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

  3. iOS开发-自动布局之autoresizingMask使用详解(Storyboard&Code)

    前言:现在已经不像以前那样只有一个尺寸,现在最少的IPHONE开发需要最少需要适配三个尺寸.因此以前我们可以使用硬坐标去设定各个控件的位置,但是现在的话已经不可以了,我们需要去做适配,也许你说可以使用 ...

  4. iOS -- autoResizingMask使用(转)

    autoResizingMask 是UIView的一个属性,在一些简单的布局中,使用autoResizingMask,可以实现子控件相对于父控件的自动布局. autoResizingMask 是UIV ...

  5. ios 中的autoresizingMask

    以前对这个知识理解的不太对,看了下面这个地址的文章后,感觉说的对,也没检验,今天实验后,发现是错的...在这里对以前读过此文的朋友表示抱歉. 原文地址如下: http://www.cnblogs.co ...

  6. iOS开发——View的autoresizingMask属性

    View的自适应属性autoresizingMask属性 每一个UIView都有一个autoresizingMask属性,这个属性是用于适应父视图的大小与子视图适应的,源码如下 enum { UIVi ...

  7. 【iOS 】UIView 中有一个autoresizingMask的属性

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

  8. ios开发之--关于UIView的autoresizingMask属性的研究

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

  9. iOS笔记之AutoresizingMask

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

随机推荐

  1. Parse how to write flash in uefi shell.

    Step: 1.     Enable 2.     Read 3.     Write 4.     Disable FI_GUID gEfiSFlashProtocolGuid = FLASH_P ...

  2. 全国地区的省份、城市、区县 最新Sql脚本

    IF (EXISTS(SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TB_Province]') AND type =' ...

  3. rabbitMQ rabbitmq-server -detached rabbitmq-server -detached rabbitmq-server -detached

    [root@localhost mnesia]# cat /etc/rabbitmq/rabbitmq-env.conf RABBITMQ_MNESIA_BASE=/home/rabbitmq/mne ...

  4. SpringMVC接受JSON参数详解及常见错误总结

    SpringMVC接受JSON参数详解及常见错误总结 SpringMVC接受JSON参数详解及常见错误总结 最近一段时间不想使用Session了,想感受一下Token这样比较安全,稳健的方式,顺便写一 ...

  5. java生成word的完美解决方案

    http://www.360doc.com/content/13/0731/10/13247663_303740756.shtml —————————————————————————————————— ...

  6. AngularJS Notes

    ng-app The ng-app directive tells AngularJS that the <div> element is the "owner" of ...

  7. 安卓程序代写 网上程序代写[原]BluetoothDevice详解

    一. BluetoothDevice简介 1. 继承关系 public static Class BluetoothDevice extends Object implement Parcelable ...

  8. Process.StandardOutput

    Namespace:  System.DiagnosticsAssembly:  System (in System.dll) Syntax   C# C++ F# VB   [BrowsableAt ...

  9. Qt中如何根据类名来实例化对象

    对于Qt 来说,是可以做到运行时,根据对象的类名字(字符串)来获得对象的实例的,这点和一些语言的反射机制是一样的. 但是在Qt中,我们需要所额外的一步,就是注册.只要做到了注册,我们就可以 自由的创建 ...

  10. 重点:QObject 的拷贝构造和赋值操作——私有

    QObject 中没有提供一个拷贝构造函数和赋值操作符给外界使用,其实拷贝构造和赋值的操作都是已经声明了的,但是它们被使用了Q_DISABLE_COPY () 宏放在了private区域.因此所有继承 ...