//截取self.view全图
// UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque,0.0);
// [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
// UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
// UIGraphicsEndImageContext();
UIImage* image = nil;
// UIGraphicsBeginImageContext(_myScrollView.contentSize);//这个方法不清晰
//函数原型为:
//void UIGraphicsBeginImageContextWithOptions(CGSize size, BOOL opaque, CGFloat scale);
//size——同UIGraphicsBeginImageContext
//opaque—透明开关,如果图形完全不用透明,设置为YES以优化位图的存储。
//scale—–缩放因子
UIGraphicsBeginImageContextWithOptions(_myScrollView.contentSize, NO,0.0);//开始截图
{
CGPoint savedContentOffset = _myScrollView.contentOffset;
CGRect savedFrame = _myScrollView.frame;
_myScrollView.contentOffset = CGPointZero;
_myScrollView.frame = CGRectMake(0, 0, _myScrollView.contentSize.width, _myScrollView.contentSize.height -40.5);
[_myScrollView.layer renderInContext:UIGraphicsGetCurrentContext()];
image = UIGraphicsGetImageFromCurrentImageContext();
_myScrollView.contentOffset = savedContentOffset;
_myScrollView.frame = savedFrame;
}
UIGraphicsEndImageContext(); //结束截图
最后的image就是图片