1.系統默認的顏色設置
1 //無色 2 cell.selectionStyle=UITableViewCellSelectionStyleNone; 3 //藍色,也就是系統默認的顏色 4 cell.selectionStyle=UITableViewCellSelectionStyleBlue; 5 //灰色 6 cell.selectionStyle=UITableViewCellSelectionStyleGrap;
2.自定義UITableViewCell選中后的背景顏色和背景圖片
1 UIColor* color=[[UIColor alloc]initWithRed:0.0 green:0.0 blue:0.0 alpha:1];//通過RGB來定義顏色 2 cell.selectedBackgroundView=[[UIView alloc]initWithFrame:cell.frame]autorelease]; 3 cell.selectedBackgroundView.backgroundColor=[UIColor ***]或color; 4 5 自定義選中后的背景圖片 6 cell.selectedBackgroundView=[[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"123.png"]]autorelease]; 7 設置UITableViewCell中的字體顏色時用 8 cell.textLabel.highlightedTextColor=[UIColor **color];
3.定義UITableViewCell的樣式
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
不設置accessoryType時是這樣的
設置accessoryType后是這樣的
發沒發現其中的差別,要仔細看哦,不仔細看可能看不出來哦
accessoryType有如下幾種
typedef enum { UITableViewCellAccessoryNone, UITableViewCellAccessoryDisclosureIndicator, UITableViewCellAccessoryDetailDisclosureButton, UITableViewCellAccessoryCheckmark } UITableViewCellAccessoryType;
4.隱藏UITableViewCell的分隔線
[chatTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
UITableViewCellSeparatorStyle有如下幾種
typedef enum { UITableViewCellSeparatorStyleNone, UITableViewCellSeparatorStyleSingleLine, UITableViewCellSeparatorStyleSingleLineEtched } UITableViewCellSeparatorStyle;
5設置UITableViewCell之間分隔線的顏色
[chatTableViewsetSeparatorColor:[UIColor blueColor]];
還有其他顏色可以設置,你們可以自已試試
請多多指教
原文地址:
http://blog.csdn.net/a6472953/article/details/7532212