开发者

How to change the color of selected row and unselected row in UITableview?

I want to change the color of selected row and unselected row in uitableview when开发者_如何学Python user select a particular row from it.

Tell me the sample code or any link for it. Thanks in advance


cell.contentView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.25];

By changing the value of red, green, blue, you can change the color of the cell when selected.


In the cellForRowAtIndexpath method,

set backgroundView and selectedBackgroundView property of UITableViewCell.

You just create a new UIView object with required background color and assign that view to the property.

UIView *normalView = [[UIView alloc] initWithFrame:cell.bounds];
normalView.backgroundColor = [UIColor blueColor];
cell.backgroundView = normalView;
[normalView release];

Similarly for selectedBackgroundView.

Then finally set

[cell.textLabel setBackgroundColor:[UIColor clearColor]];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜