//开启上下文
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);
用户登录
还没有账号?立即注册
用户注册
投稿取消
| 文章分类: |
|
还能输入300字
上传中....
柏林小姐