func configureHeaderView(header: UITableViewHeaderFooterView, forSection section: Int) {
switch section {
case 0:
header.textLabel!.text = "BASES \(selectedBases)/\(menuItem.freeBases!.integerValue)"
case 1:
header.textLabel!.text = "TOPPINGS \(selectedToppings)/\(menuItem.freeToppings!.integerValue)"
case 2:
header.textLabel!.text = "PREMIUMS \(selectedPremiums)/\(menuItem.freePremiums!.integerValue)"
case 3:
header.textLabel!.text = "DRESSINGS \(selectedDressings)/\(menuItem.freeDressings!.integerValue)"
default:
break
}
}
func tableView(tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
let headerView = view as? UITableViewHeaderFooterView
headerView!.textLabel!.frame = CGRectMake(0, 10, tableView.frame.size.width, 25)
headerView!.textLabel!.backgroundColor = UIColor(red: 230.0/255.0, green: 230.0/255.0, blue: 230.0/255.0, alpha: 1.0)
headerView!.textLabel!.font = UIFont(name: "BrandonGrotesque-Medium", size: 10)
headerView!.textLabel!.textColor = UIColor.blackColor()
headerView!.textLabel!.textAlignment = .Center
}
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if Array(sectionToAddOnsDictionary.keys).count < 2 {
return nil
}
var headerView = tableView.dequeueReusableHeaderFooterViewWithIdentifier("MYOSHeaderView")
if headerView == nil {
tableView.registerClass(UITableViewHeaderFooterView.classForCoder(), forHeaderFooterViewReuseIdentifier: "MYOSHeaderView")
headerView = tableView.dequeueReusableHeaderFooterViewWithIdentifier("MYOSHeaderView")
}
configureHeaderView(headerView!, forSection: section)
return headerView
}