如何快速比较颜色 [英] How to compare a color in swift
本文介绍了如何快速比较颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试比较颜色,但我无法使用 isEqual
方法,因为我正在尝试比较 UICollectionViewCell
的背景颜色.
I am trying to compare colors but I cannot use the isEqual
method because I am trying to compare the color of the background of a UICollectionViewCell
.
在这种情况下比较颜色的正确方法是什么?
What is the correct way to compare colors in this situation?
if(cell!.layer.backgroundColor! == UIColor.redColor().CGColor)
{
cell?.layer.backgroundColor = UIColor.redColor().CGColor
}
推荐答案
Try CGColorEqualToColor(_ color1: CGColor!, _ color2: CGColor!) ->布尔
.
这篇关于如何快速比较颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文