プロパティselectedBackgroundViewを変更すると正しく、最も簡単な方法を追加します。私が選択色に変更するには、次のコードを使用します。
//セット選択色
UIView *myBackView = [[UIView alloc] initWithFrame:cell.frame];
myBackView.backgroundColor = [UIColor colorWithRed:1 green:1 blue:0.75 alpha:1];
cell.selectedBackgroundView = myBackView;
[myBackView release];
またはuは、これを使用する可能性がありますが...ここで
は私が解決するために遭遇した最も効率的な方法ですこの問題は、(cell.textLabel.textおよび/またはcell.detailTextLabel.textを使用している場合、これは同様にテキストラベルの背景のホワイトカラーの世話をする)willDisplayCellデリゲートメソッドを使用します。
(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { ... }
このデリゲートメソッドは、セルの色と呼ばれる
は、使用するときのような細胞ではなく、テーブルビューを介して制御されます。
(UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath { ... }
だから、セルデリゲートメソッドの本体内に次のコードを追加しますセルの代替色を使用するか、関数呼び出しを使用してテーブルのすべてのセルを同じ色にします。
if (indexPath.row % 2)
{
[cell setBackgroundColor:[UIColor colorWithRed:.8 green:.8 blue:1 alpha:1]];
}
else [cell setBackgroundColor:[UIColor clearColor]];
が重複する可能性(HTTP [UITableViewCellのの青のハイライトの色を変更するには?]:// stackoverflowの。com/questions/2553746/how-to-change-the-blue-highlight-of-auableableviewcell) –