美文网首页#iOS#HeminWoniOS 开发 iOS开发
UIView 设置指定几个角为圆角

UIView 设置指定几个角为圆角

作者: 这样的我321 | 来源:发表于2016-05-13 15:26 被阅读1130次

    //初始化UIView

        UIView * view = [UIView alloc]initWithFrame:CGRectMake(0,0,[UIScreen mainScreen].bounds.size.width,[UIScreen mainScreen].bounds.size.height)];

    [view setBackgroundColor:[UIColor White]];

    [self.view addSubview:view];

    //设置view左侧上UIRectCornerTopLeft 和 左侧下UIRectCornerBottomLeft为5的圆角

    UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerBottomLeft cornerRadii:CGSizeMake(5, 5)];

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

    layer.frame = view.bounds;

    layer.path = path.CGPath;

    view.layer.mask = layer;

    //设置view 全部角为圆角

    viewT.layer.cornerRadius = 10;//设置那个圆角大小

    viewT.layer.masksToBounds = YES;//设置YES是保证添加的图片覆盖视图的效果

    相关文章

      网友评论

        本文标题:UIView 设置指定几个角为圆角

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