以下の様な記述で UIButton の外観の画像データがアプリの Documents 以下に test.png という名称で 保存されます。他のGUIについても同様の方法でファイルに保存できます。
(サンプルの全体はこちらからDLして下さい)
- (IBAction)run:(id)sender { UIGraphicsBeginImageContext(self.button.frame.size); CGContextRef context = UIGraphicsGetCurrentContext(); [self.button.layer renderInContext:context]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); NSData *data = UIImagePNGRepresentation(image); NSString *filePath = [NSString stringWithFormat:@"%@/test.png" , [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]]; NSLog(@"%@", filePath); if ([data writeToFile:filePath atomically:YES]) { NSLog(@"OK"); } else { NSLog(@"Error"); } [data release]; }