UIView的常见属性
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
UIView的常见属性的更多相关文章
- iOS开发之UIView的常见属性
1.所有控件都继承自UIView,UIView的常见属性如下: @property(nonatomic,readonly) UIView *superview;获得自己的父控件对象 @property ...
- iOS基础--UIView的常见属性
UIView的常见属性以及方法 @property(nonatomic,readonly) UIView *superview; // 获得自己的父控件对象 @property(nonatomic,r ...
- UIView常见属性总结
一 UIVIew 常见属性 .frame 位置和尺寸(以父控件的左上角为原点(,)) .center 中点 (以父控件的左上角为原点(,)) .bounds 位置和尺寸(以自己的左上角为原点 (,)) ...
- CALayer基本介绍与常见属性
属性框架:QuartzCore CA: CoreAnimation -> 核心动画,所有的核心动画都是添加给layer的! 与UIView的区别: 1.layer负责内容的展示,不接受任何用户交 ...
- UIScrollView常见属性
什么是UIScrollView •设备的屏幕大小是极其有限的,因此直接展示在用户眼前的内容也相当有限 • •当展示的内容较多,超出一个屏幕时,用户可通过滚动手势来查看屏幕以外的内容 • •普通的UIV ...
- UIPickerView常见属性、常见方法(包括代理方法和数据源方法)的一些说明
一.UIPickerView 1.UIPickerView的常见属性 // 数据源(用来告诉UIPickerView有多少列多少行) @property(nonatomic,assign) id< ...
- 格而知之2:UIView的autoresizingMask属性探究
UIView的autoresizingMask属性,是用在当一个UIView实例的父控件的尺寸发生变化时,来自动调整UIView实例在父控件中的位置与尺寸的.autoresizingMask属性是一个 ...
- UIButton 头文件常见属性和方法
UIButton头文件常见属性 1.属性 contentEdgeInsets: default is UIEdgeInsetsZero.设置内容四边距,默认边距为0 @property(nonatom ...
- ios2--UIView的常见属性
// // ViewController.m // 06-UIView的常见属性 // #import "ViewController.h" @interface ViewCont ...
随机推荐
- 四元数(Quaternion)详细讲解以及在图形图像编程中的使用
关于四元数介绍可以直接看wiki,写的很详细了. 四元数的基本运算:http://www.linuxgraphics.cn/opengl/opengl_quaternion.html,代码有些问题. ...
- 动态链接库(DLL)的使用
2013-07-04 http://blog.csdn.net/blpluto/article/details/5715182 感觉挺好,推荐去看看.
- HW4.45
public class Solution { public static void main(String[] args) { int count = 0; for(int i = 1; i < ...
- POJ-2442 Sequence K路归并问题
题目链接:http://poj.org/problem?id=2442 问题一:K个有序表合成一个有序表,元素共有n个.用堆优化 问题二:两个序列的前n小的元素.堆优化. 这题就是问题二的扩展,每次处 ...
- centos svn快速搭建
搭建SVN服务,有效的管理代码,以下三步可以快速搞定. 1.安装 #yum install subversion 判断是否安装成功 [root@]# svnserve --version 有了SVN软 ...
- php5.5 yum源
PHP官网在下载页面中只有源代码下载,当然使用编译安装也是可以的,但是使用二进制包安装会非常快速.虽然PHP官网没有提供二进制安装包,但是它推荐了两个第三方的YUM源(CentOS中默认的YUM安装的 ...
- HDU 1102 Constructing Roads (最小生成树)
最小生成树模板(嗯……在kuangbin模板里面抄的……) 最小生成树(prim) /** Prim求MST * 耗费矩阵cost[][],标号从0开始,0~n-1 * 返回最小生成树的权值,返回-1 ...
- POJ3107--Godfather(树的重心)
vector建图被卡了..改为链式前向星500ms过的..差了四倍多?... 表示不太会用链表建图啊..自己试着写的,没看模板..嗯..果然错了..落了一句话orz 树的重心就是找到一个树中一个点,其 ...
- 学习Visitor Pattern 有感而发!override and overload
通过阅读各位前辈写的博文,像吕震宇,idior,李建忠WebCast等,对Visitor模式有一定的了解,有感而记录下来,以备忘. Visitor Pattern 假设了这样一个场景,在一个类型层次中 ...
- JSP中解决获取请求参数中文乱码问题
分两种情况: 1.获取访问请求参数时乱码 解决方法:构造一个新的String String user = new String(request.getParameter("user" ...