UIView常用属性与方法

@interface UIView : UIResponder<NSCoding, UIAppearance, UIAppearanceContainer, UIDynamicItem>

/**
* 通过一个frame来初始化一个UI控件
*/
- (id)initWithFrame:(CGRect)frame; // YES:能够跟用户进行交互
@property(nonatomic,getter=isUserInteractionEnabled) BOOL userInteractionEnabled; // default is YES // 控件的一个标记(父控件可以通过tag找到对应的子控件)
@property(nonatomic) NSInteger tag; // default is 0 // 图层(可以用来设置圆角效果\阴影效果)
@property(nonatomic,readonly,retain) CALayer *layer; @end @interface UIView(UIViewGeometry)
// 位置和尺寸(以父控件的左上角为坐标原点(0, 0))
@property(nonatomic) CGRect frame; // 位置和尺寸(以自己的左上角为坐标原点(0, 0))
@property(nonatomic) CGRect bounds; // 中点(以父控件的左上角为坐标原点(0, 0))
@property(nonatomic) CGPoint center; // 形变属性(平移\缩放\旋转)
@property(nonatomic) CGAffineTransform transform; // default is CGAffineTransformIdentity // YES:支持多点触摸
@property(nonatomic,getter=isMultipleTouchEnabled) BOOL multipleTouchEnabled; // default is NO
@end @interface UIView(UIViewHierarchy)
// 父控件
@property(nonatomic,readonly) UIView *superview; // 子控件(新添加的控件默认都在subviews数组的后面, 新添加的控件默认都显示在最上面\最顶部)
@property(nonatomic,readonly,copy) NSArray *subviews; // 获得当前控件所在的window
@property(nonatomic,readonly) UIWindow *window; // 从父控件中移除一个控件
- (void)removeFromSuperview; // 添加一个子控件(可以将子控件插入到subviews数组中index这个位置)
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index; // 交换subviews数组中所存放子控件的位置
- (void)exchangeSubviewAtIndex:(NSInteger)index1 withSubviewAtIndex:(NSInteger)index2; // 添加一个子控件(新添加的控件默认都在subviews数组的后面, 新添加的控件默认都显示在最上面\最顶部)
- (void)addSubview:(UIView *)view; // 添加一个子控件view(被挡在siblingSubview的下面)
- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview; // 添加一个子控件view(盖在siblingSubview的上面)
- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview; // 将某个子控件拉到最上面(最顶部)来显示
- (void)bringSubviewToFront:(UIView *)view; // 将某个子控件拉到最下面(最底部)来显示
- (void)sendSubviewToBack:(UIView *)view; /**系统自动调用(留给子类去实现)**/
- (void)didAddSubview:(UIView *)subview;
- (void)willRemoveSubview:(UIView *)subview; - (void)willMoveToSuperview:(UIView *)newSuperview;
- (void)didMoveToSuperview;
- (void)willMoveToWindow:(UIWindow *)newWindow;
- (void)didMoveToWindow;
/**系统自动调用**/ // 是不是view的子控件或者子控件的子控件(是否为view的后代)
- (BOOL)isDescendantOfView:(UIView *)view; // returns YES for self. // 通过tag获得对应的子控件(也可以或者子控件的子控件)
- (UIView *)viewWithTag:(NSInteger)tag; // recursive search. includes self /**系统自动调用(留给子类去实现)**/
// 控件的frame发生改变的时候就会调用,一般在这里重写布局子控件的位置和尺寸
// 重写了这个写方法后,一定调用[super layoutSubviews];
- (void)layoutSubviews; @end @interface UIView(UIViewRendering)
// YES : 超出控件边框范围的内容都剪掉
@property(nonatomic) BOOL clipsToBounds; // 背景色
@property(nonatomic,copy) UIColor *backgroundColor; // default is nil // 透明度(0.0~1.0)
@property(nonatomic) CGFloat alpha; // default is 1.0 // YES:不透明 NO:透明
@property(nonatomic,getter=isOpaque) BOOL opaque; // default is YES // YES : 隐藏 NO : 显示
@property(nonatomic,getter=isHidden) BOOL hidden; // 内容模式
@property(nonatomic) UIViewContentMode contentMode; // default is UIViewContentModeScaleToFill
@end @interface UIView(UIViewAnimationWithBlocks)
+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion;
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion; + (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations;
+ (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;
@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. STL 中的链表排序

    一直以来学习排序算法, 都没有在链表排序上下太多功夫,因为用得不多.最近看STL源码,才发现,原来即使是链表,也能有时间复杂度为O(nlogn)的算法, 大大出乎我的意料之外,一般就能想到个插入排序. ...

  2. bootstrap圆角

    圆角问题 这里为圆角, .;}   原因是我是用li 标签的line-height给他撑开的,所以会出现圆角,所以我没有定义side的background-color加上就好了             ...

  3. save a web page as a single file (mht format) using Delphi code

    Here's how to save a web page as a single file (mht format) using Delphi code: uses CDO_TLB, ADODB_T ...

  4. git分支更新代码命令

    第一步: 查看状态  git status 第二步: 全部添加  git add --all 第三步: 再次查看状态  git status 第四步: 提交      git commit -m '备 ...

  5. 9. Palindrome Number(判断整型数字是否是回文,直接暴力即可)

    Determine whether an integer is a palindrome. Do this without extra space. class Solution: def isPal ...

  6. javascript Date对象 之 时间转字符串

    javascript Date对象 --> 时间转字符串: 测试代码: <!DOCTYPE html> <html lang="en"> <he ...

  7. 笔记2:Jmeter核心组件

    资料来源:开源优测 微信公众号,作者:苦叶子 Jmeter核心组件 1.Thread Group(线程组) 2.逻辑控制器,配置元件,定时器,前置处理器,Sample,后置处理器,断言,监听器: 3. ...

  8. Linux负载均衡--LVS(IPVS)

    一.LVS简介 LVS是Linux Virtual Server的简称,也就是Linux虚拟服务器, 是一个由章文嵩博士发起的自由软件项目,现在已经是 Linux标准内核的一部分.LVS是一种叫基于T ...

  9. zabbix监控php-fpm的性能

    zabbix监控php-fpm主要是通过nginx配置php-fpm的状态输出页面,在正则取值 要nginx能输出php-fpm的状态必须要先修改php-fpm的配置,这个配置没有开启nginx 就没 ...

  10. 【I/O】File常见用法总结

    java.io.File file可能是一个文件或者文件夹. 获取目录列表(全部/过滤) import java.io.File; import java.io.FilenameFilter; imp ...