I have added two images, first one shows what i want and second one shows what is happening. I want uitableview header to go behind the status bar as shown in first image. deployment target is 9.2
and second one is
I assume you are using Autolayout
so you can either constraint tableView's .top
margin to its super view's .top
or view controller's topLayoutGuide
property so that the table view will start from 0
:
let toItem: Any = self.topLayoutGuide
// You can change this to `self.view` to have the same effect.
view.addConstraint(
NSLayoutConstraint(item: tableView,
attribute: NSLayoutAttribute.top,
relatedBy: NSLayoutRelation.equal,
toItem: toItem,
attribute: NSLayoutAttribute.top,
multiplier: 1.0, constant: 0
)
)
Here is how it looks in my simulator:
To have the table header start below the status bar, just use layoutGuide
's .bottom
property instead of .top
:
Here you can download the test project.