(Objective-C) UIView指定方向设置圆角
2024-08-13 本文已影响0人
布呐呐u
- 左上、右上
UIView *testView = UIView.new;
testView.frame = CGRectMake(0, 0, 200, 200);
testView.center = self.center;
[self addSubview:testView];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:testView.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(10, 10)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = testView.bounds;
maskLayer.path = maskPath.CGPath;
testView.layer.mask = maskLayer;