iphone - 在将 UIImage 叠加到另一个 UIImage 上时需要一些帮助吗?

标签 iphone ios

我有一个应用程序,用户可以在发送传真之前在传真图像 (tif) 上注释签名图像。我在这里看到了一个非常好的问题:iPhone SDK - How to draw a UIImage onto another UIImage?但是我仍然无法做我正在寻找的东西。有人可以指导我,因为我是图形上下文 ETC 的新手。

最佳答案

这是您获取图像所需的操作,

CGRect faxImageRect = CGRectZero;
CGRect signatureRect = CGRectZero;

faxImageRect.size = faxImage.size;
signatureRect.size = signature.size;

// Adjust the signature's location within the fax image
signatureRect.origin = desirableLocation;

UIGraphicsBeginImageContext(faxImage.size);
[faxImage drawInRect:faxImageRect];
[signature drawInRect:signatureRect];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

到最后image将包含您要发送的图像。

此示例使用其图像的真实尺寸。你可以改变它,尽管它们可能会受到拉伸(stretch)。

关于iphone - 在将 UIImage 叠加到另一个 UIImage 上时需要一些帮助吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6390063/

相关文章:

iphone - 如何在 plist 中保存 MKMapRect

iphone - 无法使用 UILongTouchGestureRecognizer 从 MKMapView 获取坐标

ios - 为什么副本捆绑资源中的文件显示为红色?

ios - 在 Objective-C 中的按钮文本中显示数组元素

ios - Swift:在核心数据模型中搜索字符串

ios - Swift 解析来自奇怪对象的数据(几乎是 JSON)

iphone - 应用程序在i0S 6中崩溃,但在iOS 5中没有崩溃

ios - 没有兼容模式的 iPad 上的 iPhone 应用

iphone - 如何使用 UIButton 作为切换开关

iphone - 如何在没有 SIP 服务器的情况下在直接 IP 到 IP 之间进行调用