【问题标题】:'bottomLayoutGuide' was deprecated in iOS 11.0: Use view.safeAreaLayoutGuide.bottomAnchor instead of bottomLayoutGuide.topAnchor? [duplicate]'bottomLayoutGuide' 在 iOS 11.0 中已弃用:使用 view.safeAreaLayoutGuide.bottomAnchor 而不是 bottomLayoutGuide.topAnchor? [复制]
【发布时间】:2019-05-26 08:57:11
【问题描述】:

底部布局指南在 ios 11 中显示已弃用?在开发应用程序时。虽然我尝试使用布局锚但不起作用,但我附上了我的代码问题的图片

 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)

【问题讨论】:

    标签: swift


    【解决方案1】:

    使用view.safeAreaLayoutGuide.bottomAnchor 而不是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)
    }
    

    【讨论】:

      猜你喜欢
      • 2018-01-14
      • 2017-11-07
      • 1970-01-01
      • 2020-01-07
      • 2018-06-07
      • 1970-01-01
      • 1970-01-01
      • 2018-03-04
      • 2012-04-29
      相关资源
      最近更新 更多