当前位置: 代码迷 >> 综合 >> iOS设置tableViewCell的cell、textLabel和detailTextLabel背景颜色
  详细解决方案

iOS设置tableViewCell的cell、textLabel和detailTextLabel背景颜色

热度:12   发布时间:2024-01-20 19:20:12.0

//    注意:在- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath代理方法中修改textLabel和detailTextLabel的背景颜色,不会马上生效,具体原因没有深入研究(Xcode 7.1  iOS9.1环境中);



//    下面的代理方法设置,界面效果会马上响应

- (void)tableView: (UITableView*)tableView willDisplayCell: (UITableViewCell*)cell forRowAtIndexPath: (NSIndexPath*)indexPath

{

    cell.backgroundColor = [UIColor blackColor];

    cell.textLabel.backgroundColor = [UIColor redColor];

    cell.detailTextLabel.backgroundColor = [UIColor blueColor];

}