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

代码收集

//设置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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 174,831评论 25 709
  • 慢慢变成你喜欢的样子 然后变成不喜欢你的样子
    看起来不酸的橙子阅读 248评论 0 0
  • 前段时间有其他team的同事说觉得我接触的客户都很有趣,因为我最近不时会把与客户的对话写在微信上。 ...
    晖越阅读 711评论 0 0
  • 关联目录索引:重温AngularJS(一)-- 表达式、指令重温AngularJS(二)-- 模型ng-model...
    Zyao89阅读 737评论 0 0
  • 我渴望有一片海 一片能时常看的见的海 够我装满包容放进心里 和让我保持勇敢的能力 我也爱海周围的花花草草 可能的话...
    林里林外阅读 318评论 0 2