使用UIAppearance,我正在更改Table View Cell的标签颜色。这样可以正常工作,但它只会对当前看到的细胞进行着色。视图外的所有单元格(未被看到)仍然是默认颜色(黑色)。
在摘要中,该方法仅更改当前正在查看的单元格,而不是视图中的单元格(滚动到视图外)。
这是我的UIAppearance代码:
[[UILabel appearanceWhenContainedIn:[_textLabel class], nil]
setTextColor:[UIColor colorWithRed:(204.0f/255.0f) green:(204.0f/255.0f) blue:(204.0f/255.0f) alpha:1.0f]];
答案 0 :(得分:0)
我猜你这里有拼写错误,_textLabel
必须是UITableViewCell
而不是UILabel
,
[[UILabel appearanceWhenContainedIn:[YourTableViewCell class], nil]
setTextColor:[UIColor colorWithRed:(204.0f/255.0f) green:(204.0f/255.0f) blue:(204.0f/255.0f) alpha:1.0f]];
您可以在cellForRowAtIndexPath
:
static NSString *CellIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell==nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}