IOS 取消TableView点击Cell时的色背景
2014-05-08 10:33
519 查看
为了在TableView中使用自定义的UI,所以要取消掉Cell被点击时的蓝色背景。关键代码如下:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
CGRect recTableView = CGRectMake(3,102,316,324);
self.tableView =
[[UITableView alloc]initWithFrame:recTableView style:UITableViewStylePlain];
// 设置协议,意思就是UITableView类的方法交给了tabView这个对象,让完去完成表格的一些设置操作
self.tableView.delegate = self;
self.tableView.dataSource = self;
//设置TABLE VIEW背景色
self.tableView.backgroundColor = UIColor.clearColor;
//把tabView添加到视图之上
[self.view addSubview:self.tableView];
// 存放显示在单元格上的数据
NSArray *arrayCarList = [NSArrayarrayWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12", nil];
self.aData = arrayCarList;
[self.tableView setSectionIndexColor:[UIColor clearColor]];
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
[self.tableView setSeparatorColor:[UIColor clearColor]];
[self.tableView setBackgroundView:nil];
//[self.tableView setAllowsSelection:NO]; //如果TALBLEVIEW为只读的话也可以直接这样写就行了
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// 声明静态字符串型对象,用来标记重用单元格
static NSString *TableSampleIdentifier = @"BaseCell";
// 用TableSampleIdentifier表示需要重用的单元
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TableSampleIdentifier];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
cell.contentView.backgroundColor = UIColor.clearColor;
cell.backgroundColor = UIColor.clearColor;
[cell.textLabel
setHighlighted:NO];
……
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell
*cell = [tableView cellForRowAtIndexPath:indexPath];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
........
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
CGRect recTableView = CGRectMake(3,102,316,324);
self.tableView =
[[UITableView alloc]initWithFrame:recTableView style:UITableViewStylePlain];
// 设置协议,意思就是UITableView类的方法交给了tabView这个对象,让完去完成表格的一些设置操作
self.tableView.delegate = self;
self.tableView.dataSource = self;
//设置TABLE VIEW背景色
self.tableView.backgroundColor = UIColor.clearColor;
//把tabView添加到视图之上
[self.view addSubview:self.tableView];
// 存放显示在单元格上的数据
NSArray *arrayCarList = [NSArrayarrayWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12", nil];
self.aData = arrayCarList;
[self.tableView setSectionIndexColor:[UIColor clearColor]];
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
[self.tableView setSeparatorColor:[UIColor clearColor]];
[self.tableView setBackgroundView:nil];
//[self.tableView setAllowsSelection:NO]; //如果TALBLEVIEW为只读的话也可以直接这样写就行了
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// 声明静态字符串型对象,用来标记重用单元格
static NSString *TableSampleIdentifier = @"BaseCell";
// 用TableSampleIdentifier表示需要重用的单元
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TableSampleIdentifier];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
cell.contentView.backgroundColor = UIColor.clearColor;
cell.backgroundColor = UIColor.clearColor;
[cell.textLabel
setHighlighted:NO];
……
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell
*cell = [tableView cellForRowAtIndexPath:indexPath];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
........
}
相关文章推荐
- iOS 触摸 手势和tableView cell的点击冲突
- ios开发之-- tableview/collectionview获取当前点击的cell
- UITableView点击cell取消选中背景颜色
- iOS Tableable cell 自定义点击背景效果
- iOS点击TableView的cell显示弹出动画
- iOS界面不能点击(tableView 的cell 不能使用点击事件,tableView也不能上下滚动)
- tableview的cell点击和取消
- iOS开发swift中tableView的条目点击的背景和文字颜色
- ios tableview和cell背景颜色设置
- iOS界面不能点击(tableView 的cell 不能使用点击事件,tableView也不能上下滚动)
- IOS TableView 去除点击后产生的灰色背景
- iOS 点击tableView的cell,让其滚到屏幕顶部
- tableview属性 不显示cell分割线,右边小箭头取消选中 iOS 新手笔记
- ios tableview cell上面的view添加手势,两个手指同时点击cell上的view的冲突(手势冲突)
- iOS tableview cell 去除点击效果 和 选择效果
- ios UITableView 点击cell后返回正常背景
- iOS 点击cell改变背景颜色或者图片&&cell中其他部分取消高亮显示
- IOS 开发之实现取消tableView返回时cell选中的问题
- 点击tableview里的cell后改变cell的背景图片
- IOS中点击TableView的Cell跳转