sách gpt4 ăn đã đi

ios - 在另一个 UIImage 之上添加 UIImage

In lại 作者:技术小花猫 更新时间:2023-10-29 10:56:19 27 4
mua khóa gpt4 giày nike

我有两张图片:第一张是用户个人图片,第二张是图标(角标(Badge))。

我想在第一个 uiimage(用户图像)的左下角添加第二个 uiimage(图标),并将它们保存到一个新的 Uiimage 中。

Cảm ơn

câu trả lời hay nhất

试试这个方法:

-(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];

关于ios - 在另一个 UIImage 之上添加 UIImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10523122/

27 4 0
技术小花猫
Hồ sơ

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress