0

プログラムで作成された (XIB が関連付けられていない) テーブル ビューを含むビューがあります。一部のセルの背景色を明るい灰色にしたい。だから私はこれを試しました:

cell.contentView.backgroundColor = [UIColor colorWithRed:(230/255.f) green:(230/255.f) blue:(230/255.f) alpha:1.0];

しかし、結果は次のとおりです (問題はもちろん、セルの背景が完全に灰色であることです)。

ここに画像の説明を入力

これも試してみましたが、前と同じ結果になりました。

UIView *cell_view = [[UIView alloc] init];
[cell_view setBackgroundColor:[UIColor colorWithRed:(230/255.f) green:(230/255.f) blue:(230/255.f) alpha:1.0]];
[cell setBackgroundView:cell_view];

何も機能していないようです。ご協力いただきありがとうございます。

4

6 に答える 6

0

このコードは私のために働いています。

このコードを試してください:

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

UIColor *CellColor = [UIColor colorWithRed:(230/255.f) green:(230/255.f) blue:(230/255.f) alpha:1.0];
cell.backgroundColor = CellColor;

}

于 2013-06-05T13:09:28.883 に答える