zoukankan      html  css  js  c++  java
  • [UIKit学习]01.关于UIView,frame,bounds,center

    UIView是Cocoa大多控件的父类,本身不带事件。

    UIView的常见用法

    • @property(nonatomic,readonly) UIView *superview;
    • 获得自己的父控件对象
    • @property(nonatomic,readonly,copy) NSArray *subviews;
    • 获得自己的所有子控件对象
    • @property(nonatomic) CGAffineTransform transform;
    • 控件的形变属性(可以设置旋转角度、比例缩放、平移等属性)(特别对于一些没法控制尺寸的控件,用tranform有奇效~~~
    • clipsToBounds=Yes;
    • 设置是否裁剪内容,就是当子控件超出父控件范围时,是否可见。

    UIView的增删查

    • 增加    - (void)addSubview:(UIView *)view;
    • 删除    - (void)removeFromSuperview
    • 查询    - (UIView *)viewWithTag:(NSInteger)tag;

    UIView的插入

    // 将子控件view插入到subviews数组的index位置
    - (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;
    
    // 将子控件view显示到子控件siblingSubview的下面
    - (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview;
    // 将子控件view显示到子控件siblingSubview的上面
    - (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview;
    
    // 将子控件view放到数组的最后面,显示在最上面
    - (void)bringSubviewToFront:(UIView *)view;
    // 将子控件view放到数组的最前面,显示在最下面
    - (void)sendSubviewToBack:(UIView *)view;

    frame

    frame是相对于父控件的位置CGRectMake(x,y,w,h)

    bounds

    bounds是以自己左上角为坐标原点,所以一般x,y都是0

    center

    center指的是控件中心点相对于父控件的位置

  • 相关阅读:
    嵌入式Linux的启动过程
    【转载】vim 中文帮助手册的安装
    面向对象之编写驱动程序--中断(linux系统、s3c6410开发板)
    【转】DBCC IND / DBCC PAGE
    【转】索引查询 sys.dm_db_index_physical_stats
    【tag】Enum.HasFlag 方法
    【tag】Tuple 类 使用介绍
    【fixed point】柯里化(currying) C#实现
    SqlDataAdapter 批量更新 DataTable
    sqlCacheDependency 使用
  • 原文地址:https://www.cnblogs.com/zhangjingyangjinjin/p/5226603.html
Copyright © 2011-2022 走看看