UITableViewCell 设置
生活随笔
收集整理的這篇文章主要介紹了
UITableViewCell 设置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
選中cell
//選中第一分區的第一個cell 也可指定其它 cell
[self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionNone];
//取消選中狀態
[tableView deselectRowAtIndexPath:indexPath animated:NO];
cell 顏色
1.系統默認的顏色設置
1 //無色 2 cell.selectionStyle=UITableViewCellSelectionStyleNone; 3 //藍色,也就是系統默認的顏色 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];//通過RGB來定義顏色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 設置UITableViewCell中的字體顏色時用 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.設置UITableViewCell之間分隔線的顏色
?[chatTableViewsetSeparatorColor:[UIColor?blueColor]];
轉載于:https://www.cnblogs.com/wei8/p/3205042.html
總結
以上是生活随笔為你收集整理的UITableViewCell 设置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JS学习笔记6-JavaScript 数
- 下一篇: css毛玻璃效果白边_使用css模拟vi