0
votes

I'm trying to layout a tableview in a UIViewController with a transparent navigationBar. I already accomplished this, using this code on my custom UINavigationController:

navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationBar.shadowImage = UIImage()
navigationBar.isTranslucent = true

On my storyboard I set my tableView with its edges pinned to the safe area, except for the top one, who is pinned to the top of the super view.

Problem is that my tableView is not starting at the top of the screen but as if the navigation bar is still opaque. I check the tableView insets and all are zero. What I'm doing wrong here?

Thanks

1
Make sure you have edgesForExtendedLayout is at least containing .top. i.e set on viewDidLoad edgesForExtendedLayout = [.top] and checkE-Riddie

1 Answers

4
votes

You can try to disable the scroll view insets adjustment.

contentInsetAdjustmentBehavior is available from iOS11 so you can check the availability like in this code:

if (@available(iOS 11.0, *)) 
{
    self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} 
else 
{
    self.automaticallyAdjustsScrollViewInsets = NO;
}