1

bottom layout guide was showing deprecated in ios 11? while developing an apps.though i have try to using layout anchor but not works , i have attached picture of my code problem

 override open func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
        coordinator.animate(alongsideTransition: { (transitionCoordinatorContext) -> Void in
            let orient = UIApplication.shared.statusBarOrientation

            for (index, var layoutAnchor) in self.arrBottomAnchor.enumerated() {

                layoutAnchor.isActive = false

                switch orient {
                case .portrait:
                   layoutAnchor = self.arrViews[index].bottomAnchor.constraint(equalTo: self.bottomLayoutGuide.topAnchor)


                case .landscapeLeft,.landscapeRight :
                    layoutAnchor = self.arrViews[index].bottomAnchor.constraint(equalTo: self.bottomLayoutGuide.bottomAnchor)
RajeshKumar R
  • 15,445
  • 2
  • 38
  • 70
jahidul hasan
  • 21
  • 1
  • 4

1 Answers1

1

Use view.safeAreaLayoutGuide.bottomAnchor instead of bottomLayoutGuide.topAnchor

if #available(iOS 11.0, *) {
    layoutAnchor = self.arrViews[index].bottomAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor)
} else {
    layoutAnchor = self.arrViews[index].bottomAnchor.constraint(equalTo: self.bottomLayoutGuide.topAnchor)
}
RajeshKumar R
  • 15,445
  • 2
  • 38
  • 70