//UIView就是屏幕上的一个矩形区域
//视图上的所有可视控件都是UIView和UIView的子类
//1.创建一个View
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
//2.设置view的背景颜色
view.backgroundColor = [UIColor whiteColor];
//将View添加到窗口上
[self.window addSubview:view];
//farme是相对父视图而言的
//父视图和子视图是相对而言的
//一个视图可以有多个子视图,但是只能有一个父视图
UIView *views = [[UIView alloc]initWithFrame:CGRectMake(50, 50, 50, 50)];
views.backgroundColor = [UIColor redColor];
//将一个视图view加入到另外一个视图view中,view对views有所有权,views的引用计数加一;
[view addSubview:views];
UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(80, 80, 80, 80)];
view1.backgroundColor = [UIColor orangeColor];
[self.window addSubview:view1];
//center是改变view的中心点的位置
view.center = CGPointMake(200, 200);
UIView *green = [[UIView alloc]initWithFrame:CGRectMake(250, 250, 100, 100)];
green.backgroundColor = [UIColor darkGrayColor];
[self.window addSubview:green];
UIView *yellow = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 50, 50)];
yellow.backgroundColor = [UIColor redColor];
[green addSubview:yellow];
//结构体创建
CGRect rect = CGRectMake(0, 0, 10, 10);
CGPoint point = CGPointMake(10, 20);//(长和宽)
CGSize size = CGSizeMake(10, 30);//(size 宽和高)
//几种插入方法
UIView *orangV = [[UIView alloc]initWithFrame:CGRectMake(50, 100, 100, 30)];
orangV.backgroundColor = [UIColor redColor];
[self.window addSubview:orangV];
UIView *red = [[UIView alloc]initWithFrame:CGRectMake(50, 150, 100, 30)];
red.backgroundColor = [UIColor redColor];
[self.window addSubview:red];
UIView *blue = [[UIView alloc]initWithFrame:CGRectMake(180, 100, 150, 30)];
blue.backgroundColor = [UIColor blueColor];
// [red addSubview:blue];
//把blue放在下表为2的位置
[self.window insertSubview:blue atIndex:2];
//把red放在blue的上面
[self.window insertSubview:red aboveSubview:blue];
//把red放在blue的下卖
[self.window insertSubview:red belowSubview:blue];