zoukankan      html  css  js  c++  java
  • UIView的autoresizingMask属性

    1、解释

    在 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。

    其它的组合类似。

    2、实例

    创建一个tableView,如下:

     _videoTable = [[UITableView alloc] initWithFrame:rect style:UITableViewStylePlain];
        _videoTable.backgroundColor = [UIColor yellowColor];
        _videoTable.dataSource = self;
        _videoTable.delegate = self;
        _videoTable.autoresizingMask = UIViewAutoresizingFlexibleHeight;//1
        [self.view addSubview:_videoTable];

    将1处的代码注释、解注释可看到效果对比:

         

    底部的灰色部分是一个view,左侧图是设置table的autoresizingMask属性的效果,右侧是没有设置的效果

     

    3、参考

    http://blog.csdn.net/yuquan0821/article/details/7596545

  • 相关阅读:
    有关云计算的思考
    转载:args build and execute command lines from standard input
    云计算时代来临
    How to check the service availble
    反射小结
    JOptionPane用法java
    eclipse快捷键调试总结
    javascript 控制 html元素 显示/隐藏
    "ORA00054: 资源正忙, 但指定以 NOWAIT 方式获取资源, 或者超时失效"的快速解决方法
    麻辣豆腐与编码
  • 原文地址:https://www.cnblogs.com/benbenzhu/p/3836445.html
Copyright © 2011-2022 走看看