CGRect rect = [self.viewbounds];
UIGraphicsBeginImageContext(rect.size);
CGContextRef context =UIGraphicsGetCurrentContext();
[self.view.layerrenderInContext:context];
UIImage *image =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *data = UIImagePNGRepresentation(image);//转换成二进制文件
NSString *path = NSHomeDirectory();
NSLog(@"%@",path);
[data writeToFile:[NSStringstringWithFormat:@"%@/Documents/ss.png",path]atomically:YES];