I have a table view and I would like the cells to be of alternate colors so I have found this code :
if ((indexPath.row % 2) == 0)
cell.backgroundColor = [UIColor greyColor];
else
cell.backgroundColor = [UIColor whiteColor];
it compiles all right but when I run the app I get the following error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[UIColor greyColor]: unrecognized selector sent to class 0xfbad60'
well I usually program in android so I thought some colors were defined by default but it seems that's not the case. I am really new to this how could I define some colors something like color black="000000"? Is there a tutorial about this? I have looked around but couldn't find anything.
thks
Use GRAY !
cell.backgroundColor = [UIColor grayColor];
Apple has chosen to use gray over grey:
if ((indexPath.row % 2) == 0)
cell.backgroundColor = [UIColor grayColor];
else
cell.backgroundColor = [UIColor whiteColor];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With