UIView

//UIWindow 应用程序的窗体,每个应用程序有且只有一个窗体
    //UIView 视图类,为所有视图控件的父类
    //窗体的作用,是为了展示其他视图控件
   //相对父视图的坐标
@property(nonatomic) CGRect frame;
//相对于自己的坐标
@property(nonatomic) CGRect bounds;
//中心点
@property(nonatomic) CGPoint center;
//父视图
@property(nonatomic,readonly) UIView *superview;
//所有的子视图
@property(nonatomic,readonly,copy) NSArray *subviews;

//在最上层添加一个视图
- (void)addSubview:(UIView *)view;
//在指定层面插入一个视图
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;
//在某个视图是下级插入一个新视图
- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview;
//在某个视图的上级插入一个新视图
- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview;
//从父视图中移除(自杀)
- (void)removeFromSuperview;
//修改2个视图的层级
- (void)exchangeSubviewAtIndex:(NSInteger)index1 withSubviewAtIndex:(NSInteger)index2;
//将某个视图移到最上层
- (void)bringSubviewToFront:(UIView *)view;
//将某个视力移到最底层
- (void)sendSubviewToBack:(UIView *)view;

//判断一个视图是否是别外一个视图的子视图(如果是同一个视图也会返回yes)
- (BOOL)isDescendantOfView:(UIView *)view;
//通过tag找view
- (UIView *)viewWithTag:(NSInteger)tag;

//子视图的范围是否可以超过自己(默认是no),如果设为yes超过的部分会不显示出来
@property(nonatomic) BOOL clipsToBounds;

【停靠模式】
//允许子视图跟随,默认就是yes
@property(nonatomic) BOOL autoresizesSubviews;
//随父视图变化的效果
@property(nonatomic) UIViewAutoresizing autoresizingMask;    

UIView基础【动画效果】,三种实现方式
【一】
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
//do something
[UIView commitAnimations];

【二】
[UIView animateWithDuration:0.5 animations:^{
    //do something
    }];

【三】
[UIView animateWithDuration:0.5 animations:^{
    //do something
    } completion:^(BOOL finished){
        //动画完成后执行
    }]; 
    
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    
    //代码都写到此处
    //iOS坐标系:原点在屏幕左上角 iPhone4s (320*480)/iPhone5(320*568)
    self.window.backgroundColor = [UIColor whiteColor];
    //所有视图控件的父类
    //frame CGRect 四个值:(x,y width height)用于描述view在坐标系中的位置和大小
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(10,30,50,50)];
    //view.bounds 与frame区别 x,y 为0
    //UIColor 颜色类
    //设置View的背景颜色
    view.backgroundColor = [UIColor redColor];
    //将view添加到窗体中
    [self.window addSubview:view];
    //程序的状态栏,基础尺寸(320*20)
    //设置缓冲动画 animateWithDuration 设置动画时长
    [UIView animateWithDuration:5 animations:^{
        //改变view的frame
        //alpha 透明度, 0.0 全透明;1.0是不透明
        view.alpha =0.0;
        view.frame = CGRectMake(320-50,480-50, 50,50);
    }];
    
    
    UIView *orangeView = [[UIView alloc] initWithFrame:CGRectMake(10,10,180,180)];
    orangeView.backgroundColor = [UIColor orangeColor];
    //设置子视图的自适应模式 (设置子视图的宽、高随着父视图变化)
    orangeView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
    //作为黑色视图的子视图
    [blackView addSubview:orangeView];
    //为视图设置标记
    blackView.tag = 200;
    
    
原文地址:https://www.cnblogs.com/liudongyan/p/4399298.html