gpt4 book ai didi

uitableview - ios7 UITableViewCell SelectionStyle 不会变回蓝色

转载 作者:行者123 更新时间:2023-12-03 01:15:59 25 4
gpt4 key购买 nike

Xcode 5.0、iOS 7 并更新现有应用程序。 UITableView 选定的行现在是灰色的,而不是蓝色的。

据我所知,他们将默认的 selectionStyle 更改为灰色。但“蓝色”仍然是 IB 中的一个选项,并且 UITableViewCellSelectionStyleBlue 仍然存在。查看新的 HIG,看起来他们没有删除蓝色,并且“设置”应用程序仍然使用蓝色单元格选择。

我尝试在 IB 和代码中设置该值,但没有成功。关于我需要做什么才能恢复蓝色选择样式有什么想法吗?

最佳答案

iOS7 中只有一种选择样式,要更改您需要手动执行此操作,如下所示:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
....
UIView *bgColorView = [[UIView alloc] init];
bgColorView.backgroundColor = [UIColor colorWithRed:(76.0/255.0) green:(161.0/255.0) blue:(255.0/255.0) alpha:1.0]; // perfect color suggested by @mohamadHafez
bgColorView.layer.masksToBounds = YES;
cell.selectedBackgroundView = bgColorView;
....
return cell;
}

关于uitableview - ios7 UITableViewCell SelectionStyle 不会变回蓝色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18794080/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com