自定義cell的點擊效果(點擊的高亮顏色)

Cell的點擊效果(點擊時纔有高亮鬆開則消失)

在celldidselect方法中實現

[tableView deselectRowAtIndexPath:indexPath animated:YES];

設置點擊的背景顏色

系統默認的三種顏色樣式
//無色  
cell.selectionStyle = UITableViewCellSelectionStyleNone;  

//藍色  
cell.selectionStyle = UITableViewCellSelectionStyleBlue;  

//灰色  
cell.selectionStyle = UITableViewCellSelectionStyleGray;

//自定義的顏色
/**
 *  修改cell的控件屬性
 *  此方法中可以修改系統默認cell的各個屬性
 */
//-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath實現

cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];  //這行代碼不能省略
cell.selectedBackgroundView.backgroundColor = [UIColor xxxxxx];  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章