美文网首页Swift进阶iOS开发经验集
iOS UILabel 上方两边加圆角

iOS UILabel 上方两边加圆角

作者: 我的天空蔚蓝色 | 来源:发表于2015-11-28 11:12 被阅读4097次
     UILabel * exChangeLabel = [[UILabel alloc]initWithFrame:CGRectMake(5, 10, self.view.width-10 , 20)];      
      exChangeLabel.backgroundColor = setColor(0, 0, 0, 0.8);                exChangeLabel.textAlignment = NSTextAlignmentCenter;        exChangeLabel.textColor = [UIColor whiteColor];
    // exChangeLabel.layer.masksToBounds = YES;
    // exChangeLabel.layer.cornerRadius = 10;      
      UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:exChangeLabel.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(7, 7)];      
      CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];        maskLayer.frame = exChangeLabel.bounds;     
     maskLayer.path = maskPath.CGPath;
     exChangeLabel.layer.mask  = maskLayer; 
    

    相关文章

      网友评论

      本文标题:iOS UILabel 上方两边加圆角

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