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

Actually I found a thread asking a question like mine. but every solution that is given in this thread cannot be used in my code .. the last link I read was How to set the background color in UITableViewCell?

My problem is that I just want to change the background color of the tableviewcell with my own color. can someone help me?

+3
source share
5 answers

finnaly i found out how to solve this problem. but I decided to use an image. I announced my way to solve this problem in my other question in: is there anyone who made an application using the background for tableview and tableviewcell?

+1
source

How about something like:

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

One place you could put is your table view method willDisplayCell:forRowAtIndexPath:. Or you can subclass UITableViewCell and set it to your overridden initializer. Or you can load a cell from XIB and use Interface Builder to set the color.

+3
source

.

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

cellForRowAtIndexPath. U RGB MS Paint, - 0.0 1.0.

+2
+1

iOS 7

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{

       [cell setBackgroundColor:[UIColor colorWithRed:(221.0/255.0) green:(221.0/255.0) blue:(221.0/255.0) alpha:1.0]];

}

iOS 7, cellForRowAtIndexPath,

[cell setBackgroundColor:[UIColor colorWithRed:(221.0/255.0) green:(221.0/255.0) blue:(221.0/255.0) alpha:1.0]];
+1

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


All Articles