如何在目标c中连接两个图像?

时间:2009-12-30 04:24:44

标签: iphone objective-c uiimageview uiimage

我有两个UIImageView,我想将它们连接成一个UIImageView。为了让您知道,图像对它们有一定的透明度,因此您将看到它们。他们的大小相同。

2 个答案:

答案 0 :(得分:1)

如果要将一个imageView叠加到另一个上,只需将其backgroundColor设置为清除并将其移动,使用IB或通过代码直接设置其帧。

答案 1 :(得分:0)

嘿,如果您使用两个静态图像视图,那么您可以通过使用此代码进行屏幕截图来完成此操作

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 UIGraphicsBeginImageContext(self.view.bounds.size);
 [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; 
 UIImage *savedImg = UIGraphicsGetImageFromCurrentImageContext();//here is the final image
 UIGraphicsEndImageContext();
 [pool release];

希望这有帮助。