有没有办法将UIView捕获到当前不可见或者不在帧中的UIImage。在我现在使用的代码下面:
UIGraphicsBeginImageContextWithOptions(_myView.bounds.size, _myView.opaque, 0.0f);
[theView drawViewHierarchyInRect:_myView.bounds afterScreenUpdates:NO];
UIImage * snapshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
答案 0 :(得分:1)
试试这个 -
-(UIImage *)imageFromView:(UIView *)myView{
UIGraphicsBeginImageContextWithOptions(myView.bounds.size, myView.opaque, [UIScreen mainScreen].scale);
[myView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}