2015/11/13

[iOS][Objective-C]UITableViewCellのdetailTextLabelの背景色を変更

デバッグ目的でUITableViewCellのdetailTextLabelの背景色を変更したくて、下記のようにしても変わらなかったwww

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  UITableViewCell *cell;
  cell.detailTextLabel.backgroundColor = [UIColor redColor];
  return cell;
}
Changing UITableViewCell textLabel background color to clear
によると、
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
     [[cell textLabel] setBackgroundColor:[UIColor clearColor]];
     [[cell detailTextLabel] setBackgroundColor:[UIColor clearColor]];
}
でいけるとあったので、上のメソッドを使ったら確かに変更された。

0 コメント:

コメントを投稿