我在 IB 中添加了一个 UITableView
并设置了“委托(delegate)”和“数据源”,一切正常。接下来我想做的是更改分隔符颜色,但我能找到的唯一方法是将方法添加到委托(delegate)回调之一,我应该把它放在更好的地方吗?
我目前没有这个,但我想也许我需要从我的 Controller 中添加一个“iVar”,我可以链接到 IB 中的 UITableView
,然后设置分隔符颜色在 viewDidload
?
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView setSeparatorColor:[UIColor blackColor]];
return 65;
}
最佳答案
- (void)viewDidLoad
{
[self.tableView setSeparatorColor:[UIColor myColor]];
}
希望对您有所帮助 - 您需要 self.
才能访问它,记住。
swift 4.2
tableView.separatorColor = UIColor.red
https://stackoverflow.com/questions/3364859/