iOS进行合成方式,本人知道的又两种:
成都创新互联公司专注于企业全网整合营销推广、网站重做改版、融水网站定制设计、自适应品牌网站建设、H5网站设计、商城开发、集团公司官网建设、外贸营销网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为融水等各大城市提供网站开发制作服务。
1:使用UIImage直接合成
方法:通过上下文将要合成的图片都绘制到该上下文,然后得到合成的图片
- (UIImage*)NTESATCOverlayWith:(UIImage*)overlayImage{
UIGraphicsBeginImageContext(self.size);
[self drawAtPoint:CGPointZero];
[overlayImage drawInRect:CGRectMake(0, 0, self.size.width, self.size.height) blendMode:kCGBlendModeNormal alpha:0.9999999];
UIImage *combinedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return combinedImage;
}
2:通过UIView进行
方法:将图片都加载到一个UIView上,然后通过UIView生成图片.
- (UIImage *) p_w_picpathFromView:(UIView *)view {
// we need to size the graphics context according to the device scale
CGFloat scale = [[UIScreen mainScreen] scale];
CGSize pageSize = view.frame.size;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL,
pageSize.width*scale,
pageSize.height*scale,
8, /* bits per component*/
pageSize.width*scale * 4, /* bytes per row */
colorSpace,
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrderDefault);
CGColorSpaceRelease(colorSpace);
CGContextClipToRect(context, CGRectMake(0, 0, pageSize.width*scale, pageSize.height*scale));
CGContextScaleCTM(context, scale, scale);
[view.layer renderInContext:context];
CGImageRef p_w_picpath = CGBitmapContextCreateImage(context);
CGContextRelease(context);
UIImage *destImaage = [UIImage p_w_picpathWithCGImage:p_w_picpath scale:1 orientation:UIImageOrientationDown | UIImageOrientationDownMirrored];
CGImageRelease(p_w_picpath);
return destImaage;
}