I would like to take an image and duplicate it. Then increase it by 105% and overlay it on the original image.
What is the correct way to do this on iOS?
I would like to take an image and duplicate it. Then increase it by 105% and overlay it on the original image.
What is the correct way to do this on iOS?
这是您绘制图像然后再次将其另存为图像的基本代码:
- (UIImage *)renderImage:(UIImage *)image atSize:(CGSize)size
{
UIGraphicsBeginImageContext(size);
[image drawInRect:CGRectMake(0.0, 0.0, size.width, size.height)];
// draw anything else into the context
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
在它说“在上下文中绘制任何其他内容”的地方,您可以通过设置适当的矩形来绘制以缩小尺寸的图像。然后,renderImage
使用您希望完整图像的任何尺寸调用该方法。您可以使用CGContextSetAlpha
来设置透明度。