如何比较 UIColors? [英] How to compare UIColors?
本文介绍了如何比较 UIColors?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想检查 UIImageView 上背景的颜色设置.我试过了:
I'd like to check the color set for a background on a UIImageView. I've tried:
if(myimage.backgroundColor == [UIColor greenColor]){
...}
else{
...}
但这不起作用,即使我知道颜色是绿色,它也总是落入 else 部分.
but that doesn't work, even when I know the color is green, it always falls into the else part.
另外,有没有办法在调试控制台中输出当前颜色.
Also, is there a way to output the current color in the debug console.
p [myimage backgroundColor]
和
po [myimage backgroundColor]
不工作.
推荐答案
你试过 [myColor isEqual:someOtherColor]
吗?
这篇关于如何比较 UIColors?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文