【发布时间】:2015-11-18 09:38:05
【问题描述】:
【问题讨论】:
标签: ios objective-c uitableview
【问题讨论】:
标签: ios objective-c uitableview
斯威夫特
self.tableView.backgroundColor = UIColor.redColor()
取RGB值,做需要的充分
self.tableView.backgroundColor = UIColor(red: 200.0/255.0, green: 16.0/255.0, blue: 46.0/255.0, alpha: 1.0)
目标 C
self.tableView.backgroundColor = [UIColor redColor];
self.tableView.backgroundColor = [UIColor colorWithRed:200.0/255.0 green:200.0/255.0 blue:200.0/255.0 alpha:1.0];
【讨论】:
设置tableView backgroundColor 会改变所有tableView 的颜色,但是tableView 会被cell 覆盖。所以你看不到它。如果你想看到变化,你可以设置 cell.contentView.backgroundColor。
cell.contentView.backgroundColor = [UIColor greenColor];
【讨论】:
在您的代码中尝试此代码
self.YourTableName.backgroundColor = [UIColor PurpleColor];
self.YourTableName.backgroundColor = [UIColor colorWithRed:200.0/255.0 green:200.0/255.0 blue:200.0/255.0 alpha:1.0];
和
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SimpleCell"];
cell.backgroundColor = [UIColor clearColor];
return cell;
}
【讨论】: