从相册或拍照获得头像

2015-12-17 0 970
从相册或拍照获得头像
 //开启上下文
    UIGraphicsBeginImageContext(self.bounds.size);
    //获取上下文
    CGContextRef ctx =  UIGraphicsGetCurrentContext();
    //渲染
    [self.layer renderInContext:ctx];
    //获取截图
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    //关闭上下文
    UIGraphicsEndImageContext();
    //获取截图范围
    CGRect rect =  _iconFrame.frame;
    CGRect cutrect = CGRectMake(rect.origin.x+20, rect.origin.y+20, rect.size.width-40, rect.size.height-40);
    UIImage *cutImg = [UIImage imageWithCGImage:CGImageCreateWithImageInRect(img.CGImage, cutrect)];
    //block
    _photoBlock(cutImg);

遇见资源网 lua 从相册或拍照获得头像 http://www.ox520.com/14773.html

下一篇:

已经没有下一篇了!

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务