Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spacing between UITableViews like Settings Application

I'm new to iOS dev and I want to have spacing between certain cells like the official settings app has.

Is there a way to do this in one TableView or do I have to insert more of them?

If I have more TableViews the screen is not fully scrollable and maybe not all of them are able to show.

like image 329
Dave Avatar asked Oct 30 '16 07:10

Dave


1 Answers

To achieve a TableView that looks like the one in the settings you have to set the Style of your TableView to Grouped and use Sections for separating/grouping a certain set of TableViewCells.

Set TableView Style to "Grouped"

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return myNumberOfRows
}

func numberOfSections(in tableView: UITableView) -> Int {
    return myNumberOfSections
}

For more info about numberOfSections have a look at the UITableViewDataSource delegate.

like image 147
d.felber Avatar answered Oct 26 '22 18:10

d.felber