美文网首页
UIView的某几个角为圆角

UIView的某几个角为圆角

作者: 程序猿小武 | 来源:发表于2016-10-17 09:15 被阅读28次
    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(120, 10, 80, 80)];
    view2.backgroundColor = [UIColor redColor];
    [self.view addSubview:view2];
    //UIRectCornerBottomLeft -> 左下角 依此类推。
     UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view2.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = view2.bounds;
    maskLayer.path = maskPath.CGPath;
    view2.layer.mask = maskLayer;
    

    相关文章

      网友评论

          本文标题:UIView的某几个角为圆角

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