neoneye/SwiftyFORM

Changing background color of a button?

tehprofessor opened this issue · 4 comments

Howdy,

I can see references to styleIdentifier and styleClass but can't seem to figure out what they do or how to use them... Any tips? I'm primarily looking for a way to customize the background color of a button (e.g. red for close)? Not sure if I should just inherit and make my own customized class or if you have a sanctioned way of doing it.

Maybe something like...

  lazy var closButton: ButtonFormItem = {
    let instance = ButtonFormItem()
    instance.title("Dismiss")
    instance.backgroundColor = UIColor.redColor()
    instance.action = { [weak self] in
      self?.closeMe()
    }
    return instance
    }()

Thank you!

Great idea, extending the ButtonFormItem class with a backgroundColor.

The styleClass is currently only used for alignment across table rows. In the future I would like to code something CSS'ish for styling.

Would you be open to a PR for it (backgroundColor)? If so, are there any standards, etc you want followed I wouldn't be able to easily infer from the existing code?

PR is much appreciated. No hacks, clean code, etc.

Have a great day, @tehprofessor

Thanks to @Pizzo15 the background color is now customizable.

Example here:
https://github.com/neoneye/SwiftyFORM/blob/master/Example/Other/ButtonsViewController.swift