2010-09-23 68 views

回答

12

像這樣(從內存類型,因此它可能不是100%正確的):

// Get a UIImage from the view's contents 
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, view.contentScaleFactor); 
CGContextRef context = UIGraphicsGetCurrentContext(); 
[view.layer renderInContext:context]; 
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

// Convert UIImage to CGImage 
CGImageRef cgImage = image.CGImage; 
1

另外,還要確保你添加

#import <QuartzCore/QuartzCore.h>

你的代碼

+0

:大聲笑真的嗎? HAA – 2016-11-18 08:00:10