iOS UIView指定显示摸一个角弧形显示

关键代码:

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect: view.bounds byRoundingCorners:UIRectCornerTopLeft cornerRadii:CGSizeMake(10, 10)];

    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];

    maskLayer.frame = view.bounds;

    maskLayer.path = maskPath.CGPath;

    yearLabel.layer.mask = maskLayer;

弧形具体的方法如下:

UIRectCornerTopLeft //左上角弧形

UIRectCornerTopRight//右上角弧形

UIRectCornerBottomLeft//左下角弧形

UIRectCornerBottomRight//右下角弧形

 

若同时指定几个脚都有弧度用

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect: view.bounds byRoundingCorners:UIRectCornerTopLeft |UIRectCornerTopRight |UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];

各个弧度之间用 | 隔开就好了

 

posted on 2016-09-19 10:47  小小鸟的梦想  阅读(681)  评论(0编辑  收藏  举报