1、创建一个视图对象
UIView* myView = [[UIView alloc] initWithFrame:CGReckMake(10, 10, 10, 10)];
[self.window addSubview :myView];//将视图作为子视图添加到window中
2、动画 改变一些视图属性将会使用到动画,改变属性时创建一个动画,用于给用户传递在较短时间内的变化。UIView类做了动画展现的大部分工作,但是你仍然需要声明哪种属性改变的时候,你需要动画效果。有两种不同的类型来初始化动画 下面的UIView属性支持动画: frame,bounds,center,transform,alpha,backgroundColor,contentStretch 在iOS 4之后,使用block-based动画方法(推荐使用) 3、管理视图的层次结构 superview属性: subviews属性: window属性:
-addSubview方法
-bringSubviewToFront:(UIView *)veiw方法,将view视图移到层次结构的最顶端,使得其得以展示
-sendSubviewToBack:(UIView *)veiw方法,和上面方法正好相反
-removeFromSupview方法,
-insertSubview:(UIView *)view atIndex:(Interger)index方法
-insertSubview:(UIView *)view aboveSubview(UIView *)siblingView 方法
-insertSubview:(UIView *)view belowSubview(UIView *)siblingView 方法
-exchangeSubviewAtIndex:(NSInteger)index1 withSubviewAtIndex:(NSInteger)index2方法
-isDescendantOfView:(UIView *)view方法,判断view是不是指定视图的子视图
4、子视图的布局(layout)
-layoutSubviews方法,这个方法,默认没有做任何事情,需要子类进行重写
-setNeedsLayout方法
-layoutIfNeeded方法,立即对子视图进行布局
5、画/更新视图
-drawRect:(CGRect)rect方法
-setNeedsDisplay
-setNeedsDisplayInRect:(CGRect)invalidRect方法
6、以块展现动画的方式(animating views with block)
+ animateWithDuration:delay:options:animations:completion:
+ animateWithDuration:animations:completion:
+ animateWithDuration:animations:
+ transitionWithView:duration:options:animations:completion:
+ transitionFromView:toView:duration:options:completion:
7、在视图和坐标系统之间转换
-convertPoint:toView
-convetPoint:fromView
-convertRect:toView
-convertRect:fromView
8、跟踪视图相关的改变
-didAddSubview:
-willRemoveSubview:
-willMoveToSuperview
-didMoveToSuperview
-willMoveToWindow:
-didMoveToWindow
UIView及其子类 在指定frame 并且frame的宽高有一个等于0时并且不使用自动布局的时候 只会掉用初始化函数 和 layoutSubviews两个函数