Objective-C 截图实现

移动开发 iOS
本文为大家呈现了一个Objective-C的截图实现的方法,希望大家能够加以利用。

截取整个屏幕大小:

  1. UIGraphicsBeginImageContext(self.view.bounds.size); 
  2.         [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; 
  3.         UIImage * viewImage = UIGraphicsGetImageFromCurrentImageContext(); 
  4.         UIGraphicsEndImageContext(); 
  5.         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

责任编辑:闫佳明 来源: oschina
相关推荐

2011-07-19 17:24:31

Objective-C 对象

2013-03-27 12:54:00

iOS开发Objective-C

2011-05-11 11:20:26

Objective-C

2011-05-11 15:58:34

Objective-C

2011-08-10 18:07:29

Objective-C反射

2014-06-25 14:02:59

Objective-CKVO

2011-08-04 09:35:09

Objective-C 编码规范

2014-04-30 10:16:04

Objective-CiOS语法

2011-08-17 10:58:59

Objective-C构造函数

2011-08-03 16:55:05

Objective-C 代理

2011-07-29 16:16:30

Objective-c block

2012-06-15 09:47:48

Objective-CCategory

2012-03-07 13:43:59

Objective-C

2011-07-08 13:49:46

Objective-C UUID

2013-03-26 10:35:47

Objective-C单例实现

2011-08-04 14:58:37

Objective-C Cocoa NSString

2011-08-02 13:16:36

Objective-C 语法 函数

2011-05-11 15:45:50

内存管理Objective-C

2011-05-11 14:06:49

Objective-C

2011-05-11 13:54:08

Objective-C
点赞
收藏

51CTO技术栈公众号