iOS中的快照功能

时间:2012-10-31 06:44:29

标签: objective-c

我有一个包含3个子视图的父UIView,这里我有一个UIButton来捕捉整个视图。我用

完成了这个
UIGraphicsBeginImageContext(CGSizeMake(320,480));
CGContextRef context = UIGraphicsGetCurrentContext();

UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext(); 

[self.view.layer renderInContext:context];

这里我只需捕获名为subview1的第一个子视图。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

像这样的

Capture SubView

UIGraphicsBeginImageContext(subview1.size);
[subview1.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();