with the transition on iOS7 the separator has 15px padding on left. I know that i can remove this padding with separator inset feature on the UITableView setting in the xib file, but i need to keep heading text with padding. How to do it?
default:
with custom on separator inset to 0:
i need to keep separators like figure 2, but the header with "2013" like picture 1.
for Seperator you can set it via Storyboard
and for header make a custom header like this
give it any particular height. and give it any text. make an Array for section Headers which will contain your years.
in you cellForRowAtIndeaPath method add a view into cell like
add this into your first cell code and you are done
You can set insets on table (and header/footer) and on the cell itself:
You might not want to create a custom header view always because sometimes its a overkill or it'll need some trial and error to make it exactly like the default section title. Instead there is a simple hack which won't need to return a custom header view. Just set your separator indent to 0 and put some leading space in the title string.
UITableView
has a delegate method namedviewForHeaderInSection
. If you remove the padding an then in the delegate method add a padding and return the section header view.You can design you header view how ever you like. For setting the height of the tableView header use:
Hope it helps you... )
USING SWIFT AND STORYBOARD
In storyboard you can set different separator insets for the TableView (header) and for Cells (separators).
Set the separator inset for cell to 0, by selecting the cell in Storyboard and setting the following:
Then set the separator inset for the TableView (for the header) to 15, by selecting the TableView in Storyboard and setting the following:
OPTIONAL:
You may also need to set the margins on the cells to be zero programmatically to ensure that the separator goes all the way from left to right. Use this code if needed in your table view controller's swift file: