Swift Eureka: Update Eureka tableView's style

396 Views Asked by At

Is there a way to update Eureka's tableView style so that it shows a grouped or insetGrouped style instead of plain style?

I attempted tableView = UITableView(frame: .zero, style: .insetGrouped) in viewDidLoad but the Form is still showing plain style.

2

There are 2 best solutions below

1
Pierre-Luc Beaudoin On

It's easier than I expected: in your FormViewController's init, call super.init with the style you need.

init() {
    super.init(style: .insetGrouped)
}
0
Phuah Yee Keat On

An alternative to overriding it in init(), which force you to override another init function, you can also put it in the ViewDidLoad(), note that you need to put it before the call to super, as there's where the tableViewStyle is being used.

public override func viewDidLoad() {
    tableViewStyle = .insetGrouped
    super.viewDidLoad()
}

I have my own function that overrides FormViewController with some of these defaults, and all my EurekaForms extends from them. For example:

public class MyFormViewController: FormViewController {
    public override func viewDidLoad() {
        tableViewStyle = .insetGrouped
        super.viewDidLoad()
    }
}

All your form then can extend from this to get it insetGrouped style.