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?
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.isTranslucent = true
I faced the same problem and I was able to solve it. Here is what works for me:
public override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBar.backgroundColor = UIColor.clear
self.navigationController?.navigationBar.isTranslucent = true
if #available(iOS 11.0, *) {
collectionView.contentInsetAdjustmentBehavior = .never
} else {
// Fallback on earlier versions
}
}
And one more thing, that I found still necessary to make it working. Most probably you have your UICollectionView/UITableView/UIScrollview aligned to top of Safe Area. Change this constraint to be aligned to top of super view instead.
And that's it. Isn't it straightforward and intuitive? Thanks Apple.