ios开发:UIView的层级位置关系设置和旋转变形阴影等属性

一、/*************UIView-层次关系***************/

/*************UIView-层次关系***************/
    //添加视图:addSubview
    [self.view addSubview:view5];
    //移除视图:removeFromSuperview
//    [view5 removeFromSuperview];
    //将某个视图移动到最上面  bringSubviewToFront:
    [self.view bringSubviewToFront:view1];
    //将某个视图移动到最下面   sendSubviewToBack:
    [self.view sendSubviewToBack:view1];
    //将某一个视图移动到另一个视图的上面
    [self.view insertSubview:view1 aboveSubview:view3];
    //将某一个视图移动到另一个视图的下面
    [self.view insertSubview:view1 belowSubview:view2];
    //将某个视图放到指定的位置
//    [self.view insertSubview:view1 atIndex:3];
    //交换两个视图的位置
    [self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:4];

二、View的设置

    //变形属性是以中心点为基准的
    //变形属性:transform
    //大小变形:CGAffineTransformMakeScale  width*sx   heigth*sy
    viewTransform.transform = CGAffineTransformMakeScale(10, 0.5);
    //角度变形:CGAffineTransformMakeRotation
    viewTransform.transform = CGAffineTransformMakeRotation(0);//角度实现,大小变形                                                  就不会被实现了后面覆盖前面的
    //NSStringFromCGPoint  将CGPoint类型转成字符串类型
    NSLog(@"%@",NSStringFromCGPoint(viewTransform.center));
    //圆角设置:layer
    //圆角大小:cornerRadius   正方形边长的一半为圆
    viewLayer.layer.cornerRadius = 30;
    //边框设置:borderWidth
    viewLayer.layer.borderWidth = 5;
    //设置边框颜色:borderColor  默认黑色  [UIColor greenColor].CGColor
    viewLayer.layer.borderColor = [UIColor greenColor].CGColor;
    viewLayer.layer.borderColor = [[UIColor greenColor] CGColor];
    //是否切割子视图超出圆角的部分  :  YES:切割掉   默认NO:不切割
    //如果masksToBounds=YES  阴影效果出不来
    viewLayer.layer.masksToBounds = NO;
    //阴影
    //阴影的透明度:shadowOpacity  默认0.0
    viewLayer.layer.shadowOpacity = 1.0;
    //阴影的偏移量:shadowOffset
    viewLayer.layer.shadowOffset = CGSizeMake(50, 50);
    //阴影的颜色:shadowColor
    viewLayer.layer.shadowColor = [UIColor blueColor].CGColor;
    //阴影角度:shadowRadius   带有虚化的效果
    viewLayer.layer.shadowRadius = 30;

你可能感兴趣的:(ios开发:UIView的层级位置关系设置和旋转变形阴影等属性)