这里经过的图像是具有透明背景的不同形状的PNG。除了合并它们(工作正常),我想给新图像一个像素厚的轮廓。但我似乎无法做到这一点。
(所以只是为了澄清一下,我是围绕上下文中实际形状的轮廓,而不是整个图像周围的矩形。)
+ (UIImage *)mergeBackgroundImage:(UIImage *)backgroundImage withOverlayingImage:(UIImage *)overlayImage{
UIGraphicsBeginImageContextWithOptions(backgroundImage.size, NO, backgroundImage.scale);
[backgroundImage drawInRect:CGRectMake(0, 0, backgroundImage.size.width, backgroundImage.size.height)];
[overlayImage drawInRect:CGRectMake(backgroundImage.size.width - overlayImage.size.width, backgroundImage.size.height - overlayImage.size.height, overlayImage.size.width, overlayImage.size.height)];
//Add stroke.
UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return result;
}
谢谢你的时间!
马库斯