我的视图中有两个图像,我需要混合这两个图像。但问题是无法得到完美的融合。
图像混合代码
CGSize newSize = CGSizeMake(_backGroundImage.frame.size.width, _backGroundImage.frame.size.height);
UIGraphicsBeginImageContext( newSize );
[_backGroundImage.image drawInRect:CGRectMake(_backGroundImage.frame.origin.x,_backGroundImage.frame.origin.y,_backGroundImage.frame.size.width,_backGroundImage.frame.size.height) blendMode:kCGBlendModeNormal alpha:1.0];
[_foreGroundImage.image drawInRect:CGRectMake(_foreGroundImage.frame.origin.x,_foreGroundImage.frame.origin.y,_foreGroundImage.frame.size.width,_foreGroundImage.frame.size.height) blendMode:kCGBlendModeColor alpha:0.5];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[_resultImage setImage:newImage ];
我也尝试过不同的混合模式但无法得到结果。
请帮我解决这个问题
请更改此行
[_foreGroundImage.image drawInRect:CGRectMake(_foreGroundImage.frame.origin.x,_foreGroundImage.frame.origin.y,_foreGroundImage.frame.size.width,_foreGroundImage.frame.size.height) blendMode:kCGBlendModeLighten alpha:0.5];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)