两张图片合并
-(UIImage *)addImage:(UIImage *)p_w_picpath1 toImage:(UIImage *)p_w_picpath2
{
UIGraphicsBeginImageContext(p_w_picpath2.size);
//Draw p_w_picpath2
[p_w_picpath2 drawInRect:CGRectMake(0, 0, p_w_picpath2.size.width, p_w_picpath2.size.height)];
//Draw p_w_picpath1
[p_w_picpath1 drawInRect:CGRectMake(20, 20, p_w_picpath1.size.width, p_w_picpath1.size.height)];
UIImage *resultImage=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resultImage;
}
截图
- (UIImage*) combineImageFromCuttingScreen {
UIGraphicsBeginImageContext(self.baseImageView.frame.size);
UIGraphicsBeginImageContextWithOptions(self.combineView.frame.size, YES, 1);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetShouldAntialias(context, YES);
CGContextSetShouldSmoothFonts(UIGraphicsGetCurrentContext(),YES);
CGContextSaveGState(context);
CGRect r = CGRectMake(0, 0, 320, 392);
UIRectClip(r);
[self.combineView.layer renderInContext:context];
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}