ios - UITableView、Separator颜色在哪里设置?

我在 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/

相关文章:

ios - 继承 UIView 的正确做法?

ios - iPhone:检测自上次屏幕触摸以来的用户不活动/空闲时间

ios - 如何在 iPhone 上创建圆角 UILabel?

objective-c - 何时使用 enumerateObjectsUsingBlock 与 fo

ios - 在 Objective-C 中获取时间

ios - 两个 NSDate 之间的天数

ios - 从 UIColor 创建 UIImage 以用作 UIButton 的背景图像

ios - 如何确定 NSDate 是否是今天?

ios - 如何在没有自定义单元格的情况下将文本包装在 UITableViewCell 中

ios - Objective-C - 从字符串中删除最后一个字符