【发布时间】:2013-11-26 15:32:30
【问题描述】:
我正在尝试使用代码为我的应用程序设置通用配色方案,以便在项目之间移植时轻松修改它。但是,这些组件上的两种颜色不断出现略有不同的颜色。我使用以下代码来设置我的 UITableViewCell:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([indexPath row] %2 != 0)
{
[cell setBackgroundColor:kTableSecondaryCellColor];
}
}
这是我的 UILabel:
[self.lTitleBackground setBackgroundColor:kTableSecondaryCellColor];
如您所见,我只是将两个元素的背景设置为 kTableSecondaryCellColor,设置如下:
#define kTableSecondaryCellColor [UIColor colorWithRed:(158.0f / 256.0f) green:(171.0f / 256.0f) blue:(4.0f / 256.0f) alpha:0.4f]
但是,两种颜色的结果如下(绿色):
【问题讨论】:
-
你可以尝试设置cell.contentView.backgroundColor = kTableSecondaryCellColor;我认为这可能会导致问题。
-
完美,这几天一直困扰着我。您能否将其添加为答案,以便我接受。
标签: objective-c uitableview colors uilabel