1

I am trying to create a UILabel that is in between two cells,like how the table separator is presented.

Does Swift allow this with its built in functions for UITableView?

How should I go about this?

Chris
  • 361
  • 1
  • 4
  • 17

1 Answers1

1

You could use the section headers Check https://developer.apple.com/documentation/uikit/views_and_controls/table_views/adding_headers_and_footers_to_table_sections

BrunoLoops
  • 554
  • 5
  • 20
  • Ooo good point. Did not think of doing it that way. Would be a pain to create new sections dynamically. Nonetheless, this is a good way of doing it, if the table separator isn't viable. – Chris Mar 23 '21 at 15:15
  • Custom separator view handling for tableview on iOS are tricky... You could also have a custom cell "SeparatorTableViewCell" and return 2x cellCount on number of cells and return the separator cell for every odd cell, and the current cell for every even cell – BrunoLoops Mar 23 '21 at 15:31
  • 1
    @Chris That's the other workaround I see... if you need custom separators for every cell. Or add the "separator" to your custom cell and avoid using the separator as suggested: https://stackoverflow.com/questions/1374990/how-to-customize-tableview-separator-in-iphone – BrunoLoops Mar 23 '21 at 15:39
  • Thanks! I'll try the section headers way. – Chris Mar 25 '21 at 23:27