Eureka: How to setup Section title font?

Created on 5 Apr 2017  路  4Comments  路  Source: xmartlabs/Eureka

Hello,

I am unable to find a "simple" way to change section title font?
Can you help me?

Thanks a lot

awaiting response

Most helpful comment

Implement this method in your FormViewController subclass:

func tableView(_: UITableView, willDisplayHeaderView view: UIView, forSection: Int) {

        if let view = view as? UITableViewHeaderFooterView {
            view.textLabel?.textColor = .red
        }
    }

All 4 comments

+1

hey guys!
I think the easiest way is providing a custom header 馃槙 . This because the header is a HeaderFooterViewRepresentable and you can't access anything else besides the title and height for the default one.

To create a custom header you just provide a nib and then use the onSetupView callback to customize it however you want. For example, this custom header taken from the Example project to show the Eureka logo:

Section() {
    var header = HeaderFooterView<EurekaLogoViewNib>(.nibFile(name: "EurekaSectionHeader", bundle: nil))
    header.onSetupView = { (view, section) -> () in
                                view.imageView.alpha = 0;
                                UIView.animate(withDuration: 2.0, animations: { [weak view] in
                                    view?.imageView.alpha = 1
                                 })
                                 view.layer.transform = CATransform3DMakeScale(0.9, 0.9, 1)
                                 UIView.animate(withDuration: 1.0, animations: { [weak view] in
                                     view?.layer.transform = CATransform3DIdentity
                                 })
                          }
    $0.header = header
}

Cheers

Implement this method in your FormViewController subclass:

func tableView(_: UITableView, willDisplayHeaderView view: UIView, forSection: Int) {

        if let view = view as? UITableViewHeaderFooterView {
            view.textLabel?.textColor = .red
        }
    }

Look at this issue

Was this page helpful?
0 / 5 - 0 ratings