ios 开发 如何让选中的cell在最前面显示

2025-05-15 03:48:01
推荐回答(1个)
回答1:

1、:通更改UITableViewCell提供selectionStyle属性进行设置(貌似nonedefault两种style用):
[objc] view plain copy
cell.selectionStyle = UITableViewCellSelectionStyleNone;
属性其值
UITableViewCellSelectionStyleNone,//色效
UITableViewCellSelectionStyleBlue,//蓝色没效

UITableViewCellSelectionStyleGray,//灰色没效
UITableViewCellSelectionStyleDefault NS_ENUM_AVAILABLE_IOS(7_0)//默认
二:通UITableView进行设置:
[objc] view plain copy
tableView.allowsSelection = NO;
2、自定义选背景颜色

[html] view plain copy
cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
cell.selectedBackgroundView.backgroundColor = [UIColor redColor];