Eureka: 是否可以在没有自定义视图的情况下更改“节标题/页脚背景”颜色?

创建于 2017-07-06  ·  3评论  ·  资料来源: xmartlabs/Eureka

有没有一种方法可以在不使用任何自定义View或xib的情况下更改Section Header和Footer背景颜色?

  • 环境:Eureka,Xcode 8和iOS版本10.3。
section header footer question

最有用的评论

我不知道是否有Eureka特定/批准的方法,但是willDisplayHeaderView委托可以为我完成窍门:

    func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
        if let header = view as? UITableViewHeaderFooterView {
            header.backgroundView?.backgroundColor = UIColor.green
            header.textLabel?.textColor = UIColor.yellow
        }
    }

适用于显示如下的标题:

        var section = Section()
        section.header = HeaderFooterView(stringLiteral: "Ugly Header")
        form +++ section

所有3条评论

我不知道是否有Eureka特定/批准的方法,但是willDisplayHeaderView委托可以为我完成窍门:

    func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
        if let header = view as? UITableViewHeaderFooterView {
            header.backgroundView?.backgroundColor = UIColor.green
            header.textLabel?.textColor = UIColor.yellow
        }
    }

适用于显示如下的标题:

        var section = Section()
        section.header = HeaderFooterView(stringLiteral: "Ugly Header")
        form +++ section

FWIW,有一种使用onSetupView的Eureka方式,但是从3.1版开始,我认为它可能已损坏。

            var hfv = HeaderFooterView(stringLiteral: "Ugly Header")
            hfv.onSetupView = { view, _ in
                if let header = view as? UITableViewHeaderFooterView {
                     header.backgroundView?.backgroundColor = .yellow
                }
            }
            section.header = hfv

我不知道是否有Eureka特定/批准的方法,但是willDisplayHeaderView委托可以为我完成窍门:

    func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
        if let header = view as? UITableViewHeaderFooterView {
            header.backgroundView?.backgroundColor = UIColor.green
            header.textLabel?.textColor = UIColor.yellow
        }
    }

适用于显示如下的标题:

        var section = Section()
        section.header = HeaderFooterView(stringLiteral: "Ugly Header")
        form +++ section

@eliburke我尝试了这种方法,背景色不起作用,但是文本颜色起作用。 你能使它工作吗? 我正在使用Eureka 4.3.0

此页面是否有帮助?
0 / 5 - 0 等级