美文网首页
iOS UIBezierPath曲线绘制圆角

iOS UIBezierPath曲线绘制圆角

作者: 蚂蚁也疯狂 | 来源:发表于2018-04-24 11:15 被阅读19次
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(20, 100, 100, 100)];
    [self.view addSubview:view];
    view.backgroundColor = [UIColor greenColor];
    
    UIBezierPath * maskPath = [UIBezierPath bezierPathWithRoundedRect:view.layer.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(10.0f, 10.0f)];
    CAShapeLayer * maskLayer = [CAShapeLayer new];
    maskLayer.frame = view.layer.bounds;
    maskLayer.path = maskPath.CGPath;
    view.layer.mask = maskLayer;

相关文章

网友评论

      本文标题:iOS UIBezierPath曲线绘制圆角

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