2017-03-01 91 views
0

cellForRowAtIndexPath返回带有selectionStyleBlue的单元格。但它没有效果。选择行时使用灰色选择样式。任何想法为什么?为什么selectionStyle没有效果?

cell.selectionStyle = UITableViewCellSelectionStyleBlue; 
+1

请检查用户交互是否启用tableview/tableviewcell – Ujesh

+0

我认为它在选择行时返回灰色颜色? – Birendra

+0

**选择**行时使用灰色。 –

回答

0

selectionStyleUITableViewCellSelectionStyleBlue,如果你想实现选择的风格,那么手动给现在不存在,苹果也仅限于grayColor,

所以,

UIView *cellColor = [[UIView alloc] init]; 
cellColor.backgroundColor = [UIColor blueColor]; // Or use RGB to exact color 
cellBg.layer.masksToBounds = YES; 
_cell.selectedBackgroundView = cellColor; 

enter image description here

0

试试这个。

//泰伯维委托方法...

倍率FUNC的tableView(的tableView:UITableView的,didSelectRowAtIndexPath方法indexPath:NSIndexPath){

var selectedCell:UITableViewCell = tableView.cellForRowAtIndexPath(indexPath)! 
selectedCell.contentView.backgroundColor = UIColor.redColor() 

}

倍率FUNC的tableView(的tableView:UITableView的, didDeselectRowAtIndexPath indexPath:NSIndexPath){

var cellToDeSelect:UITableViewCell = tableView.cellForRowAtIndexPath(indexPath)! 
cellToDeSelect.contentView.backgroundColor = colorForCellUnselected 

}

相关问题