- (void)viewDidLoad {
[super viewDidLoad];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(50, 100, 100, 100)];
view.backgroundColor = [UIColor cyanColor];
[self.view addSubview:view];
// (UIRectCorner)corners
// UIRectCornerTopLeft = 1 << 0,
// UIRectCornerTopRight = 1 << 1,
// UIRectCornerBottomLeft = 1 << 2,
// UIRectCornerBottomRight = 1 << 3,
// UIRectCornerAllCorners = ~0UL
// 设置指定角的有圆角效果
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerBottomRight cornerRadii:CGSizeMake(20, 20)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = view.bounds;
// maskLayer.masksToBounds = YES;
maskLayer.borderColor = [UIColor blackColor].CGColor;
maskLayer.path = maskPath.CGPath;
view.layer.mask = maskLayer;
// Do any additional setup after loading the view, typically from a nib.
}
[super viewDidLoad];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(50, 100, 100, 100)];
view.backgroundColor = [UIColor cyanColor];
[self.view addSubview:view];
// (UIRectCorner)corners
// UIRectCornerTopLeft = 1 << 0,
// UIRectCornerTopRight = 1 << 1,
// UIRectCornerBottomLeft = 1 << 2,
// UIRectCornerBottomRight = 1 << 3,
// UIRectCornerAllCorners = ~0UL
// 设置指定角的有圆角效果
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerBottomRight cornerRadii:CGSizeMake(20, 20)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = view.bounds;
// maskLayer.masksToBounds = YES;
maskLayer.borderColor = [UIColor blackColor].CGColor;
maskLayer.path = maskPath.CGPath;
view.layer.mask = maskLayer;
// Do any additional setup after loading the view, typically from a nib.
}