Iphone C color lens

I have a table view and I would like the cells to have alternative colors, so I found this code:

if ((indexPath.row % 2) == 0) cell.backgroundColor = [UIColor greyColor]; else cell.backgroundColor = [UIColor whiteColor]; 

It compiles correctly, but when I run the application, I get the following error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[UIColor greyColor]: unrecognized selector sent to class 0xfbad60'

I usually program in android, so I thought some colors were defined by default, but it doesn't seem to be that way. I'm really new to this, how do I define some colors, for example, black = "000000"? Is there a lesson about this? I looked around, but could not find anything.

Thks

+4
source share
2 answers

Use GRAY!

 cell.backgroundColor = [UIColor grayColor]; 
+7
source

Apple decided to use gray gray:

 if ((indexPath.row % 2) == 0) cell.backgroundColor = [UIColor grayColor]; else cell.backgroundColor = [UIColor whiteColor]; 
+1
source

Source: https://habr.com/ru/post/1389263/


All Articles