Ios4 将一个图像重叠在另一个图像上

Ios4 将一个图像重叠在另一个图像上,ios4,uiimage,Ios4,Uiimage,我想在另一个图像上添加图像和一些文本,然后创建一个图像。我必须添加文本,但无法理解如何添加图像。有什么帮助吗?此代码段假定您有UIImage的命名bottomImage作为要绘制的基础图像,以及将在bottomImage(上面)上绘制的topImage。XPO、YPO是浮点数,用于描述topImage将在其中绘制的目标x、y(左上)位置,以及targetSize topImage将在bottomImage上绘制的大小 ... UIGraphicsBeginImageContext( bo

我想在另一个图像上添加图像和一些文本,然后创建一个图像。我必须添加文本,但无法理解如何添加图像。有什么帮助吗?

此代码段假定您有UIImage的命名bottomImage作为要绘制的基础图像,以及将在bottomImage(上面)上绘制的topImage。XPO、YPO是浮点数,用于描述topImage将在其中绘制的目标x、y(左上)位置,以及targetSize topImage将在bottomImage上绘制的大小

...
    UIGraphicsBeginImageContext( bottomImage.size );//create a new image context to draw offscreen
    [bottomImage drawInRect:CGRectMake(0,0,bottomImage.size.width,bottomImage.size.height)];//draw bottom image first, at original size
    [topImage drawInRect:CGRectMake(xpos,ypos,targetSize.width,targetSize.height) blendMode:kCGBlendModeNormal alpha:1];//draw the image to be overlayed second, at wanted location and size
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();//get newly drawn image context into a UIImage
    UIGraphicsEndImageContext();//stop drawing to the context
    return newImage;//return/use the newly created image

这不是线程安全的-不建议在线程中创建UIImage。

Thnx很多。。这正是我想要的:)