Swift图片名称比较 [英] Swift Image Name Compare

查看:74
本文介绍了Swift图片名称比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果box1Image中的图像名称等于"sallywin.png",我将使用以下代码进行计算.

I am using the below code to work out if the image name in box1Image is equal to "sallywin.png".

Id似乎无效.

我该如何编码?

非常感谢任何帮助

if (box1Image.image?.isEqual(UIImage(named: "smswin.png")))! {
            
            self.box1Image.image = UIImage(named:"sallywin.png")
        }

推荐答案

您不能直接比较两个相同的图像.您可以将图像获取为NSDATA,然后可以比较两个NSDATA值是否相等.

You cannot directly compare two images are same. You can get the images as NSDATA and then you can compare two NSDATA values are equal.

这篇关于Swift图片名称比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆