美文网首页iOS-Objective-C
添加阴影、边框

添加阴影、边框

作者: 追沐 | 来源:发表于2017-12-13 14:29 被阅读4次

    添加边框

    UIView *shadowView = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
    shadowView.backgroundColor = [UIColor brownColor];
    
    //边框
    shadowView.layer.borderColor = [[UIColor blackColor] CGColor];
    shadowView.layer.borderWidth = 5.0f;
    

    添加阴影

    UIView *shadowView = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
    shadowView.backgroundColor = [UIColor brownColor];
    
    //阴影,四个边都添加阴影
    shadowView.layer.shadowColor = [UIColor blackColor].CGColor;
    shadowView.layer.shadowOffset = CGSizeMake(0, 0);
    shadowView.layer.shadowOpacity = 0.5;
    shadowView.layer.shadowRadius = 10.0;
    shadowView.clipsToBounds = NO;
    

    shadowOffset这个属性可以控制阴影的偏移,为(0,0)时不偏移,分别代表在x和y轴上的偏移距离。

    相关文章

      网友评论

        本文标题:添加阴影、边框

        本文链接:https://www.haomeiwen.com/subject/ergaixtx.html