16
將UIView的表示保存到文件的最簡單方法是什麼?將UIView的表示保存到文件
我的解決辦法是,
UIGraphicsBeginImageContext(someView.frame.size);
[someView drawRect:someView.frame];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSString* pathToCreate = @"sample.png";
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(image)];
[imageData writeToFile:pathToCreate atomically:YES];
但似乎棘手,我想一定有這樣做更有效的方式。
我明白了。它似乎比我的好。 :) – 2010-06-16 08:39:32
如果您想在iPhone 4上使用雙精度分辨率,請使用UIGraphicsBeginImageContextWithOptions – 2010-06-16 08:43:23