屏幕截图:(这是在viewcontroller下的)
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//1.开启一个图形上下文
UIGraphicsBeginImageContextWithOptions(self.view.frame.size, NO, 0.0);
//2.获取图形上下文对象
CGContextRef ctx = UIGraphicsGetCurrentContext();
//3.调用view属性layer的方法 renderIncontex 把内容绘制到图形上下文中
[self.view.layer renderInContext:ctx];
//4.获取图片
UIImage * getImage = UIGraphicsGetImageFromCurrentImageContext();
//5.结束图形上下文
UIGraphicsEndImageContext();
//6.保存图片
UIImageWriteToSavedPhotosAlbum(getImage, nil, nil, nil);
});