码迷,mamicode.com
首页 > 其他好文 > 详细

Objective-C 截图

时间:2015-03-01 15:37:01      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

截取整个屏幕大小:

1 UIGraphicsBeginImageContext(self.view.bounds.size);
2  
3 [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
4      
5 UIImage * viewImage = UIGraphicsGetImageFromCurrentImageContext();
6      
7 UIGraphicsEndImageContext();
8      
9 UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil)

截取自定义大小:

1 UIGraphicsBeginImageContext(_attributedLabel.frame.size);
2 [_attributedLabel.layer renderInContext:UIGraphicsGetCurrentContext()];
3 UIImage * viewImage = UIGraphicsGetImageFromCurrentImageContext();
4 UIGraphicsEndImageContext();
5 UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

项目需要导入QuartzCore.framework

Objective-C 截图

标签:

原文地址:http://www.cnblogs.com/suye8280/p/4307114.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!