底部布局指南显示在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)
答案 0 :(得分:0)
使用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)
}