I use the code below to capture an image of the parent view to use as a background in a modal view. It no longer works in iOS 5 (the variable “parentViewImage” below is null. Can someone help?
// grab an image of our parent view
UIView *parentView = self.parentViewController.view;
UIGraphicsBeginImageContext(parentView.bounds.size);
[parentView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *parentViewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
In iOS 5 you need to use
presentingViewControllerinstead ofparentViewControllerproperty.