投稿

1月, 2013の投稿を表示しています

UITableViewCellの背景色を変更する

UITableViewの背景色を変更しようと以下のDataSourceでcellの背景色を変更しても上手くいかなかった。 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; cell.backgroundColor = [UIColor hogeColor]; return cell; } 背景色を変更するためには以下のDelegate内で指定すると上手くいくらしい… - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { cell.backgroundColor = [UIColor hogeColor]; } とりあえず、よく間違えるのでメモ…