0

我正在尝试将 2 个 uiimages 保存在一起,然后将合并后的图像放入一个名为 finalImage 的图像视图中。但是,我收到错误消息,我已为我的问题分配了标题。只是想把组合的 uiimage 放在图像视图中。

  @IBOutlet var finalImage: UIImageView!
override func viewDidLoad() {
    super.viewDidLoad()


    let bottomImage:UIImage = UIImage(named: "pic")!
    let topImage:UIImage = UIImage(named:"wall")!
    // Change here the new image size if you want
    let newSize = CGSize(width: bottomImage.size.width, height: bottomImage.size.height)
    UIGraphicsBeginImageContextWithOptions(newSize, false, bottomImage.scale)
    bottomImage.draw(in: CGRect(x: 0,y: 0,width: newSize.width,height: newSize.height))
    topImage.draw(in: CGRect(x: 0,y: 0,width: newSize.width,height: newSize.height), blendMode:CGBlendMode.normal, alpha:1.0)
    let newImage:UIImage = UIGraphicsGetImageFromCurrentImageContext()!
    UIGraphicsEndImageContext()
 //error line
   finalImage.image = newImage.images

    }
4

1 回答 1

5

你的 newImage 是 UIImage,所以放

finalImage.image = newImage

因为,你有UIImage类型,而不是[UIImage]- UIImage 对象的数组,在finalImage.image

于 2017-06-09T08:48:15.420 回答