ios中UITableViewCell選中後的顏色設置

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有如下幾種 

5設置UITableViewCell之間分隔線的顏色

 [chatTableViewsetSeparatorColor:[UIColor blueColor]];

還有其他顏色可以設置,你們可以自已試試

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章