Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOS7 UITableView grouped like in Settings App

In IOS7 the UITableView does not have indentation anymore when using style=grouped. How can enable the indentation, so that the UITableView behaves like the settings app from apple?

like image 688
Philipp Schaller Avatar asked Sep 25 '13 22:09

Philipp Schaller


1 Answers

There is a much simpler way to achieve this.

  1. Place your UITableView away from the sides. eg: using Autolayout you'd have a leading and trailing space of 15px (or whatever you want). You're now creating the 'indentation' that Apple used to give you for free with grouped table views.

  2. Adjust the layer to add corners and a border.

[[[self tableView] layer] setCornerRadius:5.0f];
[[[self tableView] layer] setBorderWidth:0.5f];
[[[self tableView] layer] setBorderColor:[[UIColor redColor] CGColor]];

(I can't post an image of the result because I don't yet have enough reputation)

like image 184
Calvin Avatar answered Oct 01 '22 16:10

Calvin