1

I have two colors variable 1.) is colorArray 2.) is color variable I need to compare on which index of array matched with color variable

I tried with what color is available in my color variable is have available in colorArray or not

let colorSource:[UIColor] = [UIColor.init(red: 255, green: 255/255, blue: 255/255, alpha: 1),
                             UIColor.init(red: 255/255, green: 0/255, blue: 0/255, alpha: 1),
                             UIColor.init(red: 255/255, green: 0/255, blue: 255/255, alpha: 1),
                             UIColor.init(red: 0/255, green: 0/255, blue: 255/255, alpha: 1),
                             UIColor.init(red: 0/255, green: 255/255, blue: 255/255, alpha: 1),
                             UIColor.init(red: 0/255, green: 255/255, blue: 0/255, alpha: 1),
                             UIColor.init(red: 255/255, green: 100/255, blue: 0/255, alpha: 1),
                             UIColor.init(red: 255/255, green: 255/255, blue: 0/255, alpha: 1)]

colorSource is color array

//This is variable and the red, blue and green value I am getting from api

var color = UIColor.init(red: CGFloat(red)/255, green: CGFloat(green)/255, blue: CGFloat(blue)/255, alpha: 1)

Now I want in my collection view cell the color matched with index it's cell color will stroke the boarder

   if color == colorSource[indexPath.row] {
        print("Hi")
    }

the above code is not executing

sham
  • 115
  • 9
  • see this for help :[How to compare colors in swift](https://stackoverflow.com/questions/27559937/how-to-compare-colors-in-swift) – Anbu.Karthik Oct 31 '19 at 12:31

0 Answers0