Jos*_*one 4 core-graphics uiimage ios ios5
我使用下面的代码捕获父视图的图像,以用作模态视图中的背景.它不再适用于iOS 5(下面的变量"parentViewImage"为null.有人可以帮忙吗?
// grab an image of our parent view
UIView *parentView = self.parentViewController.view;
UIGraphicsBeginImageContext(parentView.bounds.size);
[parentView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *parentViewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)
在iOS 5中,您需要使用presentingViewController而不是parentViewController属性.
UIView *parentView = self.presentingViewController.view;
UIGraphicsBeginImageContext(parentView.bounds.size);
[parentView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *parentViewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2366 次 |
| 最近记录: |