UIImage is equal to

前端 未结 3 928
南笙
南笙 2021-01-14 11:17

I need to check if a file loaded into an UIImage object file is equal to another image and execute some actions if so. Unfortunately, it\'s not working.

3条回答
  •  孤街浪徒
    2021-01-14 11:47

    You can go even further an implement the equality operator on UIImage, which will ease your logic when it comes to comparing images:

    func ==(lhs: UIImage, rhs: UIImage) -> Bool {
        lhs.pngData() == rhs.pngData()
    }
    

    This also enables the != operator on UIImage.

提交回复
热议问题