美文网首页
奇葩-UIButton左上角和右上角圆角

奇葩-UIButton左上角和右上角圆角

作者: 默默学习 | 来源:发表于2016-12-27 11:25 被阅读92次

代码收集

//设置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

相关文章

网友评论

      本文标题:奇葩-UIButton左上角和右上角圆角

      本文链接:https://www.haomeiwen.com/subject/wagsvttx.html