Newbie Questions Newbie Questions - 6 months ago 50
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


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