From fec7f8a82f2769ea38e650adfbe1c1dbcb6ef47b Mon Sep 17 00:00:00 2001 From: Fabrizio D'Urso Date: Sat, 11 Jul 2020 07:29:42 +0200 Subject: [PATCH] fix iOS11 warning with condition --- .../Source/OpalImagePickerRootViewController.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/OpalImagePicker/Source/OpalImagePickerRootViewController.swift b/OpalImagePicker/Source/OpalImagePickerRootViewController.swift index 004c73e..813f753 100644 --- a/OpalImagePicker/Source/OpalImagePickerRootViewController.swift +++ b/OpalImagePicker/Source/OpalImagePickerRootViewController.swift @@ -211,11 +211,17 @@ open class OpalImagePickerRootViewController: UIViewController { tabSegmentedControl.setTitle(title, forSegmentAt: 1) } + var topLayout = topLayoutGuide + + if #available(iOS 11.0, *) { + topLayout = view.safeAreaLayoutGuide.topAnchor as! UILayoutSupport + } + NSLayoutConstraint.activate([ - toolbar.constraintEqualTo(with: topLayoutGuide, receiverAttribute: .top, otherAttribute: .bottom), + toolbar.constraintEqualTo(with: topLayout, receiverAttribute: .top, otherAttribute: .bottom), toolbar.constraintEqualTo(with: view, attribute: .left), toolbar.constraintEqualTo(with: view, attribute: .right) - ]) + ]) } private func fetchPhotos() {