UIView常用属性与方法

  1. @interface UIView : UIResponder<NSCoding, UIAppearance, UIAppearanceContainer, UIDynamicItem>
  2.  
  3. /**
  4. * 通过一个frame来初始化一个UI控件
  5. */
  6. - (id)initWithFrame:(CGRect)frame;
  7.  
  8. // YES:能够跟用户进行交互
  9. @property(nonatomic,getter=isUserInteractionEnabled) BOOL userInteractionEnabled; // default is YES
  10.  
  11. // 控件的一个标记(父控件可以通过tag找到对应的子控件)
  12. @property(nonatomic) NSInteger tag; // default is 0
  13.  
  14. // 图层(可以用来设置圆角效果\阴影效果)
  15. @property(nonatomic,readonly,retain) CALayer *layer;
  16.  
  17. @end
  18.  
  19. @interface UIView(UIViewGeometry)
  20. // 位置和尺寸(以父控件的左上角为坐标原点(0, 0))
  21. @property(nonatomic) CGRect frame;
  22.  
  23. // 位置和尺寸(以自己的左上角为坐标原点(0, 0))
  24. @property(nonatomic) CGRect bounds;
  25.  
  26. // 中点(以父控件的左上角为坐标原点(0, 0))
  27. @property(nonatomic) CGPoint center;
  28.  
  29. // 形变属性(平移\缩放\旋转)
  30. @property(nonatomic) CGAffineTransform transform; // default is CGAffineTransformIdentity
  31.  
  32. // YES:支持多点触摸
  33. @property(nonatomic,getter=isMultipleTouchEnabled) BOOL multipleTouchEnabled; // default is NO
  34. @end
  35.  
  36. @interface UIView(UIViewHierarchy)
  37. // 父控件
  38. @property(nonatomic,readonly) UIView *superview;
  39.  
  40. // 子控件(新添加的控件默认都在subviews数组的后面, 新添加的控件默认都显示在最上面\最顶部)
  41. @property(nonatomic,readonly,copy) NSArray *subviews;
  42.  
  43. // 获得当前控件所在的window
  44. @property(nonatomic,readonly) UIWindow *window;
  45.  
  46. // 从父控件中移除一个控件
  47. - (void)removeFromSuperview;
  48.  
  49. // 添加一个子控件(可以将子控件插入到subviews数组中index这个位置)
  50. - (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;
  51.  
  52. // 交换subviews数组中所存放子控件的位置
  53. - (void)exchangeSubviewAtIndex:(NSInteger)index1 withSubviewAtIndex:(NSInteger)index2;
  54.  
  55. // 添加一个子控件(新添加的控件默认都在subviews数组的后面, 新添加的控件默认都显示在最上面\最顶部)
  56. - (void)addSubview:(UIView *)view;
  57.  
  58. // 添加一个子控件view(被挡在siblingSubview的下面)
  59. - (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview;
  60.  
  61. // 添加一个子控件view(盖在siblingSubview的上面)
  62. - (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview;
  63.  
  64. // 将某个子控件拉到最上面(最顶部)来显示
  65. - (void)bringSubviewToFront:(UIView *)view;
  66.  
  67. // 将某个子控件拉到最下面(最底部)来显示
  68. - (void)sendSubviewToBack:(UIView *)view;
  69.  
  70. /**系统自动调用(留给子类去实现)**/
  71. - (void)didAddSubview:(UIView *)subview;
  72. - (void)willRemoveSubview:(UIView *)subview;
  73.  
  74. - (void)willMoveToSuperview:(UIView *)newSuperview;
  75. - (void)didMoveToSuperview;
  76. - (void)willMoveToWindow:(UIWindow *)newWindow;
  77. - (void)didMoveToWindow;
  78. /**系统自动调用**/
  79.  
  80. // 是不是view的子控件或者子控件的子控件(是否为view的后代)
  81. - (BOOL)isDescendantOfView:(UIView *)view; // returns YES for self.
  82.  
  83. // 通过tag获得对应的子控件(也可以或者子控件的子控件)
  84. - (UIView *)viewWithTag:(NSInteger)tag; // recursive search. includes self
  85.  
  86. /**系统自动调用(留给子类去实现)**/
  87. // 控件的frame发生改变的时候就会调用,一般在这里重写布局子控件的位置和尺寸
  88. // 重写了这个写方法后,一定调用[super layoutSubviews];
  89. - (void)layoutSubviews;
  90.  
  91. @end
  92.  
  93. @interface UIView(UIViewRendering)
  94. // YES : 超出控件边框范围的内容都剪掉
  95. @property(nonatomic) BOOL clipsToBounds;
  96.  
  97. // 背景色
  98. @property(nonatomic,copy) UIColor *backgroundColor; // default is nil
  99.  
  100. // 透明度(0.0~1.0)
  101. @property(nonatomic) CGFloat alpha; // default is 1.0
  102.  
  103. // YES:不透明 NO:透明
  104. @property(nonatomic,getter=isOpaque) BOOL opaque; // default is YES
  105.  
  106. // YES : 隐藏 NO : 显示
  107. @property(nonatomic,getter=isHidden) BOOL hidden;
  108.  
  109. // 内容模式
  110. @property(nonatomic) UIViewContentMode contentMode; // default is UIViewContentModeScaleToFill
  111. @end
  112.  
  113. @interface UIView(UIViewAnimationWithBlocks)
  114. + (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion;
  115. + (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion;
  116.  
  117. + (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations;
  118. + (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay usingSpringWithDamping:(CGFloat)dampingRatio initialSpringVelocity:(CGFloat)velocity options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion;
  119. @end

UIKit继承结构

UIView常用属性与方法/UIKit继承结构的更多相关文章

  1. UIView的一些常用属性和方法

    UIView的一些常用属性和方法 1. UIView的属性 UIView继承自UIResponder,拥有touches方法. - (instancetype)initWithFrame:(CGRec ...

  2. UITableView常用属性和方法 - 永不退缩的小白菜

    UITableView常用属性和方法 - 永不退缩的小白菜 时间 2014-05-27 01:21:00  博客园精华区原文  http://www.cnblogs.com/zhaofucheng11 ...

  3. SVG DOM常用属性和方法介绍(1)

    12.2  SVG DOM常用属性和方法介绍 将以Adobe SVG Viewer提供的属性和方法为准,因为不同解析器对JavaScript以及相关的属性和方法支持的程度不同,有些方法和属性是某个解析 ...

  4. javascript的函数、创建对象、封装、属性和方法、继承

    转自原文javascript的函数.创建对象.封装.属性和方法.继承 一,function 从一开始接触到js就感觉好灵活,每个人的写法都不一样,比如一个function就有N种写法 如:functi ...

  5. Node.js process 模块常用属性和方法

    Node.js是常用的Javascript运行环境,本文和大家发分享的主要是Node.js中process 模块的常用属性和方法,希望通过本文的分享,对大家学习Node.js http://www.m ...

  6. ios基础篇(四)——UILabel的常用属性及方法

    UILabel的常用属性及方法:1.text //设置和读取文本内容,默认为nil label.text = @”文本信息”; //设置内容 NSLog(@”%@”, label.text); //读 ...

  7. 第190天:js---String常用属性和方法(最全)

    String常用属性和方法 一.string对象构造函数 /*string对象构造函数*/ console.log('字符串即对象');//字符串即对象 //传统方式 - 背后会自动将其转换成对象 / ...

  8. JavaScript中Number常用属性和方法

    title: JavaScript中Number常用属性和方法 toc: false date: 2018-10-13 12:31:42 Number.MAX_VALUE--1.79769313486 ...

  9. iOS UIView控件的常用属性和方法的总结

    一 UIVIew 常见属性1.frame 位置和尺寸(以父控件的左上角为原点(0,0))2.center 中点 (以父控件的左上角为原点(0,0))3.bounds 位置和尺寸(以自己的左上角为原点 ...

随机推荐

  1. Bootstrap 简介二

    什么是 Bootstrap? Bootstrap 是一个用于快速开发 Web 应用程序和网站的前端框架.Bootstrap 是基于 HTML.CSS.JAVASCRIPT 的. 历史 Bootstra ...

  2. 调试ASP.NET网站IIS环境问题解决方法汇总

    调试网站时出现错误,错误如下: 1. 分析器错误消息: 创建 RewriterConfig 的配置节处理程序时出错: 无法生成临时类(result=1).error CS2001: 未能找到源文件“C ...

  3. Linux常用命令(6/26)——dd命令和split命令

    dd:用指定大小的块拷贝一个文件,并在拷贝的同时进行指定的转换. 以可选块长度复制文件,默认情况下从标准输入设备输出到标准输出设备.复制过程中,还可以对文件进行一些转换. dd命令可以指定block的 ...

  4. promise两个参数的具体作用

    Promise通常配合then方法来链式的使用,then方法里面第一个回调函数表示成功状态,也就是resolve通过.then调用,第二个是失败状态-reject通过.Cath调用,如果默认写一个参数 ...

  5. zabbix api

    #!/usr/bin/env python # -*-coding:utf-8 -*- import requests import json class AutoZabbix: def __init ...

  6. 高并发情况下分布式全局ID

    1.高并发情况下,生成分布式全局id策略2.利用全球唯一UUID生成订单号优缺点3.基于数据库自增或者序列生成订单号4.数据库集群如何考虑数据库自增唯一性5.基于Redis生成生成全局id策略6.Tw ...

  7. [POI2013]BAJ-Bytecomputer

    题目描述 A sequence of integers from the set is given. The bytecomputer is a device that allows the foll ...

  8. Android -- 工程架构,电话拨号器, 点击事件的4中写法

    (该系列整理自张泽华android视频教程) 1. android工程 各个文件夹的作用 src/  java原代码存放目录 gen/ 自动生成目录 gen 目录中存放所有由Android开发工具自动 ...

  9. Java中Collections.sort()排序详解

      public static void main(String[] args) { List<String> list = new ArrayList<String>(); ...

  10. scala学习手记38 - 方法命名约定和for表达式

    方法命名约定 之前在学习<运算符重载>一节时曾经说过一个方法命名约定:方法的第一个字符决定了方法的优先级.现在再说另一个命名约定:如果方法以冒号(:)结尾,则调用目标是运算符后面的实例. ...