Layout Getting Started Guide Deprecated in iOS 11

Since the topLayoutGuide property is topLayoutGuide in iOS 11, how can I use the top layout guide?

 backView.topAnchor.constraint(equalTo: topLayoutGuide.bottomAnchor) 
+14
autolayout swift ios11
source share
2 answers

TopLayoutGuide is deprecated in iOS 11, so we have the option to use SafeAreaLayoutGuide as follows:

  • First we can get a safeAreaLayoutGuide view
  let guide = view.safeAreaLayoutGuide 
  • Second Addition of a Limitation to the Manual

     searchBackView.topAnchor.constraint(equalTo: guide.topAnchor).isActive = true 
+19
source share

Obj-C Version:

 [[searchBackView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor constant:0] setActive:YES]; 

If you have translucent columns, note: then topLayoutGuide is below the column, for example, statusBar.

see: topLayoutGuide. Explains conditions that are important to consider.

Whereas safeAreaLayoutGuide.topAnchor will not be below NivationBars; much easier to work with.

0
source share

All Articles