ios截屏功能
2015-12-11 本文已影响193人
我的天空蔚蓝色
-(void)ShootmeDidSuccessful{
//首先开启上下文
CGSize imageSize = self.view.bounds.size;
UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0.0);
//将某个VIew的所有内容渲染到图形的上下文中
CGContextRef context = UIGraphicsGetCurrentContext();
[self.view.layer renderInContext:context];
//获得图片
UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
[UIImagePNGRepresentation(image) writeToFile:@"/Users/CC/Desktop/imageName.png" atomically:YES];
}