屏幕截图的方法

不用 2d截图   直接截图

 1 -(UIImage *)screenShots
 2 {
 3      //截取整个backview
 4     UIGraphicsBeginImageContext(self.backgroundView.bounds.size);
 5     [self.backgroundView.layer renderInContext:UIGraphicsGetCurrentContext()];
 6     UIImage *sourceImage = UIGraphicsGetImageFromCurrentImageContext();
 7     UIGraphicsEndImageContext();
 8 
 9 //在截图上画下自己需要的位置及大小
10     UIGraphicsBeginImageContext(self.mainContentView.frame.size);
11     [sourceImage drawAtPoint:CGPointMake(0, self.mainContentView.bounds.size.height - self.view.bounds.size.height)];13     UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
14     UIGraphicsGetCurrentContext();
15 
16        return image;
17 }

 

posted @ 2016-01-06 16:35  黑暗森林的歌者  阅读(198)  评论(0编辑  收藏  举报