一个或多个角切圆

2017-05-13  本文已影响0人  Captain_XR

可以直接使用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;

上一篇 下一篇

猜你喜欢

热点阅读