Search code examples
iosuitableviewapplication-settings

How to create a iOS-like settings page?


I want to make something like this for my app:

enter image description here

I tried using UITableView with static cells but I cannot get the grey blocks to separate into different groups of setting options (like the image above)

How can I add the grey blocks?


Solution

  • If I understand your question correctly, what you want to do is set the table view's style to UITableViewStyle.Grouped. This may not get you dividers of the correct height, though. To do that, you need to implement tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? and return a UIView of the appropriate height and color. You could also do it as a footer. Works either way.

    I'm not going to write out all of the code and do screen shots of where to set this stuff in the Storyboard. I wish I had that kind of time, but I don't. :) This, along with the right documentation--the "Table View Programming Guide for iOS" as suggested by @rmaddy--should get you where you want to go.