How do I round only the top two corners of a UILabel?

后端 未结 3 449
忘掉有多难
忘掉有多难 2020-12-28 23:42

I know that in iOS 3.0+ I can use

 label.layer.cornerRadius = xxx;

to round all four corners of a UILabel (as a UIView subclass), but I wa

3条回答
  •  庸人自扰
    2020-12-29 00:20

    You can do this using CALayers and masks

    CAShapeLayer *maskLayer = [CAShapeLayer layer];
    maskLayer.path = maskPath.CGPath;
    label.layer.mask = maskLayer;
    

    where maskPath is a UIBezierPath set up using bezierPathWithRoundedRect:byRoundingCorners:cornerRadii

提交回复
热议问题