2017-03-01 186 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 

}

相關問題