gpt4 book ai didi

iOS改变一些项目的颜色

转载 作者:行者123 更新时间:2023-11-29 02:41:47 25 4
gpt4 key购买 nike

我有一个 tableviewcontroller,其中有几个带有标签、文本字段等的单元格。我只想更改标签和文本字段的颜色。

我试着用那个:

[[UILabel appearance] setTextColor:[[UtilisateurManager getCurrUser] getColor]];

它有效,但问题是它改变了我的抽屉导航标签的颜色,我不想这样,我只想改变我的 tableviewcontroller 的项目颜色。

所以我试过了:

    for(UIView *v in [self.tableView subviews]) {
if ([v isKindOfClass:[UILabel class]]) {
[(UILabel *)v setTextColor:[[UtilisateurManager getCurrUser] getColor]];
}
else if ([v isKindOfClass:[UITextView class]]) {
[(UITextView *)v setTextColor:[[UtilisateurManager getCurrUser] getColor]];
} etc...
}

但它不起作用...我不明白如何在不触摸抽屉导航的情况下更新 tableviewcontroller 项目的颜色。

谢谢,

最佳答案

尝试 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

UITableViewCell *cell = ...;

for (UIView *view in [cell.contentView subviews])
{
NSLog(@"%@", view);
}

那么你应该有你的 subview ,如果我没理解错的话。

关于iOS改变一些项目的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25680984/

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