I am trying to download a view from nib, configure it and take a picture without adding it to the screen:
+ (void)composeFromNibWithImage:(UIImage*)catImage completion:(CompletionBlock)completion { NSArray *nibContents = [[NSBundle mainBundle] loadNibNamed:@"CatNib" owner:nil options:nil]; CatView *catView = [nibContents firstObject];
where the snapshot is typical:
+ (UIImage *)snapshot:(UIView *)view { UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, 0.0); [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; }
However, both catView and composite size are correct, but empty when I view the code. How can I create a UIImage from a view loaded from a tip without adding a view to the screen?
source share