//1️⃣创建
UIView *view = [[UIView alloc]init];
//设置大小(view.x , view.y , view.width , view.hight );
view.frame = CGRectMake(0, 0, 100, 100);
//initWithFrame设置标签的坐标和大小 (创建的同时设置大小)
UILabel * label1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 30)];
//设置背景色(默认微透明)
view.backgroundColor = [UIColor redColor];//直接选择颜色
view.backgroundColor = [UIColor colorWithRed:arc4random()%100/100.0 green:arc4random()%100/100.0 blue:arc4random()%100/100.0 alpha:1.0];//按照RGB来设置颜色,alpha透明度
//设置圆角(圆角弧线对应圆的半径)
view.layer.cornerRadius = 2;
//透明度[0,1],默认为1,不透明,0为透明
view.alpha = 0.3;
//设置边框宽度
view.layer.borderWidth = 2;
//边框颜色
view.layer.backgroundColor = [UIColor yellowColor].CGColor;
//view的中心位置
view.center = CGPointMake(30, 40);
//tag,标识view,(-wq,0),(0,wq),默认为0,不能设置为0,不能重复
view.tag = 1;
//设置背景图
view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"图片名字"]];
/**
*第二部分 子视图图层之间的切换
*/
UIView *redView;
UIView *yellowView;
UIView *blueView;
[self.view bringSubviewToFront:redView];//将redView切换到最上面
[self.view sendSubviewToBack:blueView];//将blueView切换到最下面
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];//将图层中第0个view与第1个view交换
[self.view insertSubview:yellowView atIndex:0];//将yelloview插入到第0个位置
[self.view insertSubview:yellowView aboveSubview:blueView];//将yellowview插入到blueview的上面
[self.view insertSubview:yellowView belowSubview:blueView];//将yellowview插入到blueview的后面
/**
*第三部分 动画
*/
//开启动画
[UIView beginAnimations:nil context:nil];
//启动的延时时间
[UIView setAnimationDelay:1];
//重复次数,默认0,应该>=0
[UIView setAnimationRepeatCount:4];
//动画持续时间
[UIView setAnimationDuration:4];
//动画结束之后响应的事件
[UIView setAnimationDidStopSelector:@selector(stop)];
//开启动画
[UIView commitAnimations];