返回顶部

收藏

从相册或拍照获得头像

更多
 //开启上下文
    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

收藏

0人收藏

支持

0

反对

0

发表评论