自由设置矩形的四个角为圆角

    UIView *progress = [[UIView alloc] init];

    progress.backgroundColor = [UIColor redColor];

    progress.frame = CGRectMake(20, 20, 300, 50);

    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:progress.bounds byRoundingCorners:UIRectCornerBottomLeft|UIRectCornerTopLeft cornerRadii:CGSizeMake(25, 25)];

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

    maskLayer.frame = progress.bounds;

    maskLayer.path = maskPath.CGPath;

    progress.layer.mask = maskLayer;

    [self.view addSubview:progress];

posted @ 2018-01-19 10:45  ygm900  阅读(214)  评论(0编辑  收藏  举报