0

テーブル ビューでセルを選択すると、セルの背景がすぐに青色に変わります。他の色に変更して各セルの角を丸くする方法はありますか?

4

6 に答える 6

0

UItableViewCellプロパティを使用できます

    cell.selectionStyle=UITableViewCellSelectionStyleGray; 

しかし、uには2つの選択肢しかありません..青または灰色のいずれか

于 2012-09-14T07:09:58.040 に答える
0

selectRow のときにビューをセルに設定できます。

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    UITableViewCell *cell = (UITableViewCell*)[tableView cellForRowAtIndexPath:indexPath];
    cell.selectedBackgroundView = YourView;
}
于 2012-09-14T07:30:35.473 に答える
0

cell.selectionStyle = UITableViewCellSelectionStyleGray;またはを使用しUITableViewCellSelectionStyleBlueます。角丸ケースの使用

cell.layer.cornerRadius = 5;
于 2012-09-14T07:10:50.623 に答える
0

こんにちは、これを試してみてください...

cell.selectionStyle = UITableViewCellSelectionStyleGray; // this line for selection style

ここでは3種類の選択スタイルが

1.UITableViewCellSelectionStyleBlue

2.UITableViewCellSelectionStyleGray

3.UITableViewCellSelectionStyleNone

cell.layer.cornerRadius = 8; /// this line for round corner

これがあなたを助けることを願っています...

:)

于 2012-09-14T07:12:36.117 に答える
0

使用する場合はcell.selectionStyle、3 色しか使用できません。

より多くの色を使用したい場合は、以下のコードのようなものを使用してください:

UIView *myBackView = [[UIView alloc] initWithFrame:cell.frame];
myBackView.backgroundColor = [UIColor colorWithRed:1 green:1 blue:0.75 alpha:1];
cell.selectedBackgroundView = myBackView;
[myBackView release];
于 2012-09-14T07:15:24.613 に答える