【问题标题】:How do I concatenate two images in objective c?如何在目标 c 中连接两个图像?
【发布时间】:2009-12-30 04:24:44
【问题描述】:

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

【问题讨论】:

  • 当你说连接时,你的意思是覆盖它们(把它们放在同一个地方)还是把它们放在一起?如果您的意思是叠加,当两个像素位于同一位置时,您希望发生什么——您希望如何处理透明度?
  • 我想让它们成为一个UIImageView,是的,它们的大小相同。

标签: iphone objective-c uiimageview uiimage


【解决方案1】:

如果你想将一个 imageView 覆盖在另一个之上,只需将其 backgroundColor 设置为 clear 并将其移到上面,使用 IB 或直接通过代码设置它的 frame。

【讨论】:

    【解决方案2】:

    嘿,如果您使用两个静态图像视图,那么您可以通过使用此代码截取屏幕截图来做到这一点

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

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-12
      • 1970-01-01
      • 1970-01-01
      • 2012-05-18
      • 1970-01-01
      • 2021-02-11
      • 2010-12-14
      • 2012-09-23
      相关资源
      最近更新 更多