0

我正在尝试将一些灰度图像与不同的 alpha 相结合以创建分层效果。我正在将图像加载到 UIImageView 中,并且在屏幕上看起来与预期的一样。但是,当我保存组合图像时,只有顶层被保存;是否可以创建和保存组合图像层?

我附上了图像的链接——一个是图像应该是什么样子的屏幕截图(分层),另一个是最终保存的简单单值(非分层)。

https://dl.dropboxusercontent.com/u/8263889/good.png - 这就是我想要的 https://dl.dropboxusercontent.com/u/8263889/bad.png - 这就是发生的事情。

想法?

4

1 回答 1

2

你想保存到 UIImage 吗?如果是这样,试试这个。

+ (UIImage *)imageWithView:(UIView *)view
{
  UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
  [view.layer renderInContext:UIGraphicsGetCurrentContext()];

  UIImage * img = UIGraphicsGetImageFromCurrentImageContext();

  UIGraphicsEndImageContext();

  return img;
}
于 2013-04-24T01:59:08.500 回答