iOS 图片切圆角的另外两种方式

 1:

  UIBezierPath * maskPath = [UIBezierPath bezierPathWithRoundedRect:imageView.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:imageView.bounds.size];

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

    maskLayer.frame = imageView.bounds;

    maskLayer.path = maskPath.CGPath;

    imageView.layer.mask = maskLayer;

 

2:

 

    UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, NO, 1.0);

    [[UIBezierPath bezierPathWithRoundedRect:imageView.bounds cornerRadius:imageView.frame.size.width]addClip];

    [imageView drawRect:imageView.bounds];

    

    imageView.image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

 

posted @ 2016-10-08 15:38  琼极一生  阅读(1360)  评论(0编辑  收藏  举报