清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
//开启上下文 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);