简体   繁体   中英

IOS uitableview cell selected background

I have a UItableview in my IOS app with some information in it. I changed the Selected background color to clearcolor using the following code:

UIView *bgColorView = [[UIView alloc] init];
[bgColorView setBackgroundColor:[UIColor clearColor]];
[cell setSelectedBackgroundView:bgColorView];
[bgColorView release];

There is text and 2 images in the cell, I've build this using CGRectMake. But When I select and hold a table cell the the images disappear behind what looks like a white background.

在此输入图像描述

As you can see I'm holding the "Dacnusa sibrica" cell, how can I fix this?

If you want to disable the blue selection of cells you can also set the cell's selection mode instead of modifying the background:

cell.selectionStyle = UITableViewCellSelectionStyleNone

This simply disables the blue selection when tapping the cell but still allows the cell to be selected (and thus handled by code).

使用自动布局,可以在Interface Builder中定义Selection = None (默认为灰色)。

have you used [cell.contentView addSubview:image]? use [tableView deselectRowAtIndexPath:indexPath animated:YES]; for deselecting the cell

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM