首页 > 其他 > 详细

设置图片圆角

时间:2015-07-02 17:19:12      阅读:83      评论:0      收藏:0      [点我收藏+]

   //----------第一种方法-------------------

//    _img.layer.cornerRadius = 150;

//    _img.layer.masksToBounds = YES;

//    _img.layer.contents =  [UIImage imageNamed:@"zsy.jpg"];

////    _img.image = [UIImage imageNamed:@"zsy.jpg"];

//    [_img.layer needsDisplay];

//    

    //----------第二种方法(优化了性能)-------------------

    

//    _img.layer.shouldRasterize = YES;

//    _img.layer.rasterizationScale = self.view.window.screen.scale;

//    _img.layer.cornerRadius = 150;

//        _img.layer.masksToBounds = YES;

//     _img.image = [UIImage imageNamed:@"zsy.jpg"];

//    

    //----------第三种方法(优化了性能)-------------------

    //获取图片

    UIImage *imge = [UIImage imageNamed:@"zsy.jpg"];

    //Creates a bitmap-based graphics context

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

    

    //Creates and returns a new UIBezierPath objec

    [[UIBezierPath bezierPathWithRoundedRect:_img.bounds cornerRadius:150]addClip];

    

    

//    [self.view.layer drawInContext:<#(CGContextRef)#>];

    

    

    [imge drawInRect:_img.bounds];

    _img.image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

设置图片圆角

原文:http://www.cnblogs.com/plummithly/p/4616481.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!