nghialv / Hakuba

:cherry_blossom: Cellmodel-driven tableview manager
MIT License
474 stars 40 forks source link

HeaderFooterView height, and backgroundColor #43

Closed remirobert closed 8 years ago

remirobert commented 8 years ago

Hello, I need to use an HeaderFooterView on a Section.

I created a model view :

class HeaderSectionTripViewModel: HeaderFooterViewModel {

    init() {
        super.init(view: HeaderSectionTrip.self)
    }
}

and then my HeaderFooterView view :

class HeaderSectionTrip: HeaderFooterView, HeaderFooterViewType {
    typealias ViewModel = HeaderFooterViewModel

    override func configure() {
    }
}

Now this how I add my section header :

self.hakuba.registerHeaderFooterByNib(HeaderSectionTrip.self)

let section = Section()
section.header = HeaderSectionTripViewModel()
self.hakuba.append(section)

But my HeaderView is transparent. And also I need to change the height. thanks in advance for your help.

nghialv commented 8 years ago

Hi @remirobert . If you want to set height and backgroundColor you can see the following codes.

class HeaderSectionTripViewModel: HeaderFooterViewModel {
    init() {
        super.init(view: HeaderSectionTrip.self)
        height = 50
    }
}

class HeaderSectionTrip: HeaderFooterView, HeaderFooterViewType {
    typealias ViewModel = HeaderFooterViewModel

    override func awakeFromNib() {
          super.awakeFromNib()
          backgroundColor = .yourColor()
    }

    override func configure() {
    }
}
remirobert commented 8 years ago

@nghialv thank you so much for your help !! It works

remirobert commented 8 years ago

I am back for add more precision about this issue.

http://stackoverflow.com/questions/15604900/uitableviewheaderfooterview-unable-to-change-background-color

In fact you need to had an another UIView, acting like a container. That's it. 🙀⚠️🎉