美文网首页
圆角,单个圆角,阴影,边框(都是基本的东西)

圆角,单个圆角,阴影,边框(都是基本的东西)

作者: 隔壁班小明 | 来源:发表于2016-03-21 15:53 被阅读181次

    1.加圆角

    view.layer.cornerRadius = 8;

    view.layer.masksToBounds = YES;

    2.加单个圆角

    UIBezierPath*path = [UIBezierPath bezierPathWithRoundedRect:sayWorldButton.bounds byRoundingCorners:UIRectCornerBottomLeft/*具体哪个角*/ cornerRadii:CGSizeMake(5,5)];

    CAShapeLayer*la = [[CAShapeLayer alloc] init];

    la.frame = <#要加圆角的控件#>.bounds;

    la.path= path.CGPath;

    <#要加圆角的控件#>.layer.mask = la;

    3.加阴影

    scanButton.layer.shadowColor= [UIColorblackColor].CGColor;//阴影的颜色

    scanButton.layer.shadowOffset=CGSizeMake(1,1);//阴影的偏移量配合shadowRadius达到几条边有阴影的效果

    scanButton.layer.shadowOpacity=0.5;//透明度

    scanButton.layer.shadowRadius=1;//阴影大小

    想要同是设置圆角和阴影

    scanButton.layer.masksToBounds = YES;这个属性要去掉

    4.加边框

    view.layer.borderWidth = 5;

    view.layer.borderColor = [[UIColor colorWithRed:0.52 green:0.09 blue:0.07 alpha:1] CGColor];

    相关文章

      网友评论

          本文标题:圆角,单个圆角,阴影,边框(都是基本的东西)

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