合并图片
- (UIImage *)addImage:(UIImage *)image1 toImage:(UIImage *)image2 {
CGSize size= CGSizeMake( image1.size.width,(int)v.scrollView.contentSize.height % (int)self.view.frame.size.height+image2.size.height);
UIGraphicsBeginImageContext(size);
// Draw image1
[image2 drawInRect:CGRectMake(0, (int)v.scrollView.contentSize.height % (int)self.view.frame.size.height, image2.size.width, image2.size.height)];
// Draw image2
[image1 drawInRect:CGRectMake(0, 0, image1.size.width, image1.size.height)];
UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resultingImage;
}
截图
- (UIImage *)imageFromView: (UIView *) theView atFrame:(CGRect)r
{
UIGraphicsBeginImageContext(theView.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
UIRectClip(r);
[theView.layer renderInContext:context];
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;//[self getImageAreaFromImage:theImage atFrame:r];
}
- (UIImage *)imageFromView: (UIScrollView*) theView
{
UIGraphicsBeginImageContext(theView.contentSize);
CGContextRef context = UIGraphicsGetCurrentContext();
[theView.layer renderInContext:context];
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}