gpt4 book ai didi

ios - 在 IOS 中,选定的 UITableViewCell 的灰色背景颜色来自哪里?

转载 作者:行者123 更新时间:2023-11-29 12:24:49 26 4
gpt4 key购买 nike

正如您在这个小 gif 上看到的,当您在表格 View 中选择一个单元格时,背景颜色变为灰色。

demo我想以编程方式获得这种颜色。

我已经尝试在我的 UITableViewCell 子类中访问:

self.selectedBackgroundView?.backgroundColor

self.backgroundView?.backgroundColor

但是我得到了蓝色(就像在旧版本的 iOS 中一样)

demo2

我在调试 View 层次结构中查找以找到它,但没有成功。

提前感谢您的帮助!

问候,埃里克

[编辑]我在这里尝试的是从我的单元格中获取背景颜色以将其设置在我的单元格内的 subview 上。

最佳答案

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

cell.backgroundColor = [UIColor clearColor];

UIView *bgColorView = [[UIView alloc] init];

// CHoose the color you want to show when cell is selected
bgColorView.backgroundColor = [UIColor colorWithRed:255.0f/255.0f green:250.0f/255.0f blue:240.0f/255.0f alpha:0.1f];

bgColorView.layer.cornerRadius = -17;
bgColorView.layer.masksToBounds = YES;
[cell setSelectedBackgroundView:bgColorView];

关于ios - 在 IOS 中,选定的 UITableViewCell 的灰色背景颜色来自哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29539997/

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