Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compare a color in swift

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
}
like image 767
stacky stacky Avatar asked Apr 14 '16 02:04

stacky stacky


1 Answers

Try CGColorEqualToColor(_ color1: CGColor!, _ color2: CGColor!) -> Bool.

like image 118
Inhan Avatar answered Oct 01 '22 23:10

Inhan