代碼收集
//設(shè)置view左上角、右上角的為圓角
UIButton *exclusiveButton = [UIButton buttonWithType:UIButtonTypeCustom];
exclusiveButton.frame = CGRectMake(200, 200, 100, 100);
exclusiveButton.backgroundColor = [UIColor lightGrayColor];
[exclusiveButton setTitle:@"專屬客戶" forState:0];
exclusiveButton.tag = 1;
[self.view addSubview:exclusiveButton];
//設(shè)置圓角
UIBezierPath *maskPath1 = [UIBezierPath bezierPathWithRoundedRect:exclusiveButton.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerTopLeft cornerRadii:CGSizeMake(15, 15)];
CAShapeLayer *maskLayer1 = [[CAShapeLayer alloc] init];
maskLayer1.frame = exclusiveButton.bounds;
maskLayer1.path = maskPath1.CGPath;
exclusiveButton.layer.mask = maskLayer1;
效果
Snip20161227_6.png