美文网首页
一个或多个角切圆

一个或多个角切圆

作者: Captain_XR | 来源:发表于2017-05-13 10:46 被阅读0次

可以直接使用UIBezierPath指定一个或多个角路径,图形上下文切圆角

UIView * view = [[UIView alloc]initWithFrame:CGRectMake(50, 50, 100, 100)];

view.backgroundColor = [UIColor redColor];

[self.view addSubview:view];

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners: UIRectCornerTopLeft|UIRectCornerBottomRight cornerRadii:CGSizeMake(50,50)];

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

maskLayer.frame = view.bounds;

maskLayer.path = maskPath.CGPath;

view.layer.mask = maskLayer;

相关文章

网友评论

      本文标题:一个或多个角切圆

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