//将当前的手机屏幕上的视图控件的view拍照 并保存到手的album中
- (IBAction) camera {
UIAlertView *alert = [[UIAlertViewalloc]initWithTitle:@"Image Saved"
message:[NSStringstringWithFormat:@"This Chart has been saved to your Photo album. You can view, email and print the Chart using the Apple Photos app. "]
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
UIGraphicsBeginImageContext(self.view.bounds.size); //currentView 当前的view
[self.view.layerrenderInContext:UIGraphicsGetCurrentContext()];//将当前的view的layer 加入当前的图形上下文
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
/* 1. UIGraphicsBeginImageContext方法 按照制定大小CGSize创建一个基于位图的图形上下文并使之成为当前上下文。
2. UIGraphicsGetCurrentContext() 返回当前图形上下文
3. UIGraphicsEndImageContext() 删除当前基于位图的图形上下文从堆栈的顶部。
4. UIImageWriteToSavedPhotosAlbum(,,,)将图像保存到当地的album
*/
}