Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change background color of UITableViewCell using my own color combination

actually i have found some thread that asking question like mine. but every solution that given in those thread can not be use in my code.. the last link i was read is How to customize the background color of a UITableViewCell?

my problem is i just want to change my tableviewcell background color with my own color. can somebody help me??

like image 691
R. Dewi Avatar asked Dec 01 '25 20:12

R. Dewi


2 Answers

How about something like:

[myCell setBackgroundColor:[UIColor colorWithRed:0.2 blue:0.5 green:0.2 alpha:1]];

One place you could put this would be your table view's willDisplayCell:forRowAtIndexPath: data source method. Or else you could subclass UITableViewCell and set it in your overridden initializer. Or you could load the cell from a XIB and use Interface Builder to set the color.

like image 105
alexantd Avatar answered Dec 04 '25 12:12

alexantd


try this..

cell.backGroundColor = [UIColor colorWithRed:190.0/255.0 blue:190.0/255.0 green:190.0/255.0 alpha:1.0];

Write this code in cellForRowAtIndexPath function. U will get these kind of different RGB combinations simply from MS Paint and alpha is the opacity ranging in between 0.0 to 1.0.

like image 36
iOSiOS Avatar answered Dec 04 '25 12:12

iOSiOS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!