Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set edgesForExtendedLayout to none in Swift 3

Tags:

ios

swift

swift3

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.

like image 805
David Seek Avatar asked Oct 29 '16 03:10

David Seek


3 Answers

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

like image 115
matt Avatar answered Oct 16 '22 09:10

matt


self.edgesForExtendedLayout = .init(rawValue: 0)
like image 26
Leslie Fang Avatar answered Oct 16 '22 09:10

Leslie Fang


SWIFT 5 solution

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

   self.edgesForExtendedLayout = []
}
like image 1
Teja Kumar Bethina Avatar answered Oct 16 '22 07:10

Teja Kumar Bethina