Newbie Questions Newbie Questions - 1 year ago 102
Swift Question

TableView Header Text Issue

i have a bit of a problem with spacing as seen here : (Excuse my bad drawing skills :\ )

Bad Drawing Example + Spacing Issue

Can anyone tell me how to fix this spacing issue ? i can't find a solution to it ... Here is my code:

override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let headerText = UILabel()
headerText.textColor = UIColor.darkGrayColor()
switch section{
case 0:
headerText.textAlignment = .Right
headerText.text = "הבר המועדף עליכם חסר? שתפו אותנו ונוסיף"
case 1:
headerText.textAlignment = .Right
headerText.text = "יש לכם רעיון לשיפור האפליקציה? שתפו אותנו :)"
headerText.textAlignment = .Right
headerText.text = ""
//Any Other Customizations

return headerText

Answer Source

Implement the heightForHeaderInSection delegate method and return the desired height.

func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
    return 35.0//write here your desired value. This will be your table's header height
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download