Robert Varga Robert Varga - 1 year ago 361
Swift Question

ios 11 transparent navigation bar

Creating a transparent navigation bar no longer works with ios 11.
I get this black bar at the top because the table view doesn't come under the bar anymore (the insets in the storyboard are set properly to start from 0)
Any ideas why?

enter image description here

self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.isTranslucent = true

Answer Source

if you have used tableView,add code:

if (@available(iOS 11.0, *)) {
    self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
    self.automaticallyAdjustsScrollViewInsets = NO;
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download