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有如下几种 

2.设置UITableViewCell之间分隔线的颜色

 [chatTableViewsetSeparatorColor:[UIColor blueColor]];

posted @ 2013-07-22 11:53  wei8  阅读(275)  评论(0)    收藏  举报