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;

即可。

原文地址:https://www.cnblogs.com/ilovewindy/p/3977907.html