代码收集
//设置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];
//设置圆角
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效果
网友评论