UITableViewCell 设置
選中cell
//選中第一分區(qū)的第一個(gè)cell 也可指定其它 cell
[self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionNone];
//取消選中狀態(tài)
[tableView deselectRowAtIndexPath:indexPath animated:NO];
cell 顏色
1.系統(tǒng)默認(rèn)的顏色設(shè)置
1 //無(wú)色 2 cell.selectionStyle=UITableViewCellSelectionStyleNone; 3 //藍(lán)色,也就是系統(tǒng)默認(rèn)的顏色 4 cell.selectionStyle=UITableViewCellSelectionStyleBlue; 5 //灰色 6 cell.selectionStyle=UITableViewCellSelectionStyleGrap;2.自定義UITableViewCell選中后的背景顏色和背景圖片
1 UIColor* color=[[UIColor alloc]initWithRed:50/255.0 green:50/255.0 blue:50/255.0 alpha:1];//通過(guò)RGB來(lái)定義顏色2 cell.selectedBackgroundView=[[UIView alloc]initWithFrame:cell.frame]autorelease];
3 cell.selectedBackgroundView.backgroundColor=[UIColor ***]或color;
4 自定義選中后的背景圖片 6 cell.selectedBackgroundView=[[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"backimg.png"]]autorelease];
5 設(shè)置UITableViewCell中的字體顏色時(shí)用 8 cell.textLabel.highlightedTextColor=[UIColor **color];
3.定義UITableViewCell的樣式
??
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;accessoryType有如下幾種
typedef enum {UITableViewCellAccessoryNone,UITableViewCellAccessoryDisclosureIndicator,UITableViewCellAccessoryDetailDisclosureButton,UITableViewCellAccessoryCheckmark } UITableViewCellAccessoryType;Cell分隔
1.隱藏UITableViewCell的分隔線
? ??[chatTableView?setSeparatorStyle:UITableViewCellSeparatorStyleNone];
UITableViewCellSeparatorStyle有如下幾種? typedef enum {UITableViewCellSeparatorStyleNone,UITableViewCellSeparatorStyleSingleLine,UITableViewCellSeparatorStyleSingleLineEtched } UITableViewCellSeparatorStyle;2.設(shè)置UITableViewCell之間分隔線的顏色
?[chatTableViewsetSeparatorColor:[UIColor?blueColor]];
轉(zhuǎn)載于:https://www.cnblogs.com/wei8/p/3205042.html
總結(jié)
以上是生活随笔為你收集整理的UITableViewCell 设置的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: JS学习笔记6-JavaScript 数
- 下一篇: css毛玻璃效果白边_使用css模拟vi