如何比较UIColors? [英] How to compare UIColors?
本文介绍了如何比较UIColors?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想检查UIImageView上的背景颜色集。我试过:
if(myimage.backgroundColor == [UIColor greenColor]){
...}
else {
...}
即使我知道颜色是绿色,它总是落入else部分。
此外,是否有一种方法在调试控制台输出当前颜色。 p>
p [myimage backgroundColor]
b $ b
和
po [myimage backgroundColor]
$
解决方案您尝试过<$ p>
c $ c> [myColor isEqual:someOtherColor] ?I'd like to check the color set for a background on a UIImageView. I've tried:
if(myimage.backgroundColor == [UIColor greenColor]){ ...} 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]
and
po [myimage backgroundColor]
don't work.
解决方案Have you tried
[myColor isEqual:someOtherColor]
?这篇关于如何比较UIColors?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文