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指的是控件中心点相对于父控件的位置

  • 相关阅读:
    基础网络技术--学习网络的的道路漫长啊
    华为nova8se和vivoS7e的区别哪个好
    Java.awt实现一个简单的围棋
    HashMap put原理详解(基于jdk1.8)
    Paper Pal:一个中英文论文及其代码大数据搜索平台
    【u116】最短路计数
    【u108】取数游戏
    【u106】3D模型
    【topcoder SRM 652 DIV2 250】ValueOfString
    【u103】绘制二叉树
  • 原文地址:https://www.cnblogs.com/zhangjingyangjinjin/p/5226603.html
Copyright © 2011-2022 走看看