尝试更改 UITableViewCell
文本 UIColour
(服装单元格)将使文本变成白色且看不见,而不是仅在触摸 UITableViewCell
时,我可以看到文字。
为什么将 UIColour
设置为不是 blackColor
的 UITableViewCell
将不起作用?
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell =
[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier
forIndexPath:indexPath];
if (!indexPath.row) {
NSDictionary *dic= [[GlobalData sharedGlobals].categories
objectAtIndex:indexPath.section];
cell.textLabel.text = [dic objectForKey:@"title"]; // only top row showing
cell.textLabel.font = [UIFont fontWithName:@"Arial Rounded MT Bold"
size:22];
cell.textLabel.textColor = [UIColor colorWithRed:177
green:218
blue:229
alpha:1];
//cell.textLabel.backgroundColor = [UIColor colorWithRed:218
green:241
blue:245
alpha:1];
} else {
NSMutableArray *typesOfSection =
[[GlobalData sharedGlobals].typesByCategories
objectAtIndex:indexPath.section];
NSDictionary *type = [typesOfSection objectAtIndex:indexPath.row-1];
NSString *titleOfType = [type objectForKey:@"title"];
cell.textLabel.text = titleOfType;
cell.textLabel.textColor = [UIColor colorWithRed:122
green:181
blue:196
alpha:1];
cell.textLabel.font = [UIFont fontWithName:@"Arial Rounded MT Bold"
size:22];
//cell.textLabel.text = @"check";
cell.accessoryView = nil;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
return cell;
}
当这样做的时候:
cell.textLabel.textColor = [UIColor redColor];
它的工作..
最佳答案
您基本上是将单元格的文本颜色设置为白色。 RGB 值应介于 0.0 和 1.0 之间。
试试这个
[UIColor colorWithRed:122.0/255.0 green:181.0/255.0 blue:196.0/255.0 alpha:1.0];
关于ios - 更改 TableView 单元格颜色将不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22501885/