首页 > 代码库 > iOS:改变UITableViewCell的选中背景色

iOS:改变UITableViewCell的选中背景色

要改变UITableViewCell选中时的背景色,需要在
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)方法中添加如下代码:

// 设置cell选中的背景色UIView *selectionColor = [[UIView alloc] init];selectionColor.backgroundColor = [UIColor colorWithRed:(2/255.0)                                                 green:(94/255.0)                                                  blue:(130/255.0)                                                 alpha:1];cell.selectedBackgroundView = selectionColor;

即可。

iOS:改变UITableViewCell的选中背景色