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

  • 相关阅读:
    102. 教程:重装谷歌浏览器的教程
    IGBT知识普及
    [刷机资源] 荣耀8 E5 B391 V2 ROM集合 Xposed DPI调整等 N多自定义功能 Kangvip@HRT( 2017-9-28)
    ITPUB附件下载免输验证码 (实际下载地址的规则)
    花生壳内网穿透不再支持国外IP!
    golang 如何开发windows窗口界面
    golang 热重启
    强化go get命令
    go mod get go-git timeout
    golang单一职责原则接口设计例子
  • 原文地址:https://www.cnblogs.com/zhangjingyangjinjin/p/5226603.html
Copyright © 2011-2022 走看看