开发者

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 c开发者_如何学运维olor with my own color. can somebody help me??


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.


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.


another link that help this problem... UITableViewCell color issues with custom table view background


finnaly i found out how to solve this problem. but i was choose to use an image. I was declare my way to solve it in my another question in : is there somebody who made an application using background for tableview and tableviewcell?


Before iOS 7 Simply add this method

- (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]];

}

Now in iOS 7 if you put this code in cellForRowAtIndexPath it will work

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜