私は2つの画像を持っています:最初の画像はユーザーの個人的な画像であり、2番目の画像はアイコン(バッジ)です。
最初のuiimage(ユーザーの画像)の左下隅に2番目のuiimage(アイコン)を追加して、新しいUiimageに保存したいと思います。
ありがとう
私は2つの画像を持っています:最初の画像はユーザーの個人的な画像であり、2番目の画像はアイコン(バッジ)です。
最初のuiimage(ユーザーの画像)の左下隅に2番目のuiimage(アイコン)を追加して、新しいUiimageに保存したいと思います。
ありがとう
この方法を試してください:
-(UIImage *)drawImage:(UIImage*)profileImage withBadge:(UIImage *)badge
{
UIGraphicsBeginImageContextWithOptions(profileImage.size, NO, 0.0f);
[profileImage drawInRect:CGRectMake(0, 0, profileImage.size.width, profileImage.size.height)];
[badge drawInRect:CGRectMake(0, profileImage.size.height - badge.size.height, badge.size.width, badge.size.height)];
UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resultImage;
}
次の方法で使用できます。
UIImage *myBadgedImage = [self drawImage:profileImage withBadge:badgeImage];
これを試して:
CGFloat scale = [self currentScale];
if (scale > 1.5)
UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, scale);
else
UIGraphicsBeginImageContext(view.frame.size);
[image1 drawInRect:CGRectMake(0, 0, w1, h1)];
[image2 drawInRect:CGRectMake(0, 0, w2, h2)];
UIImage* screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();