41

The problem is that my View, containing a UIView and a UITableView within a ScrollView, gets hidden under the UINavigationBar if set translucent.

I have considered several threads like this, but they all suggest to set:

self.edgesForExtendedLayout = UIRectEdgeNone

In Swift 2, this code was:

self.edgesForExtendedLayout = .None

I have updated to Xcode 8.1 and Swift 3.0.1 today, but I can't find anything in the release notes about this matter.

The compiler tells me, that .None got changed to .none, but after edit, that .none does not exist. Changing it to .top did not had any effect.

The tableView is setup programatically and putting insets does not help because I have a scrollView with a UIView on top of the UITableView that is hidden under the UINavigationBar.

What am I missing? Help is very appreciated.

Community
  • 1
  • 1
David Seek
  • 16,783
  • 19
  • 105
  • 136

4 Answers4

136

Set it to []. That is the same as none.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • i even need to wait 10 minutes now before i can accept your answer. that did not happen since a while question: is `[]` always the same as `.none` or just in that case? i wasn't able to find anything – David Seek Oct 29 '16 at 03:51
  • Yes, `[]` is the same as `.none` as matt indicates. – Scott Corscadden Mar 10 '17 at 19:36
15
self.edgesForExtendedLayout = .init(rawValue: 0)
shim
  • 9,289
  • 12
  • 69
  • 108
Leslie Fang
  • 159
  • 2
2

SWIFT 5 solution

override func viewWillAppear(_ animated: Bool) {
   super.viewWillAppear(animated)

   self.edgesForExtendedLayout = []
}
Teja Kumar Bethina
  • 3,486
  • 26
  • 34
0

I don't know how but I just added the following code in my viewDidLoad() and it solves my problem.

self.navigationController?.navigationBar.isTranslucent = false
shim
  • 9,289
  • 12
  • 69
  • 108
Abdul Qayum
  • 179
  • 7