2010-09-23 33 views

Trả lời

12

Như thế này (gõ từ bộ nhớ, vì vậy nó có thể không chính xác 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

Ngoài ra hãy chắc chắn rằng bạn thêm

#import <QuartzCore/QuartzCore.h>

mã của bạn

+0

: P lol thực sự? haa –

Các vấn đề liên quan