gpt4 book ai didi

swift - iOS 11.0 中已弃用“bottomLayoutGuide” : Use view. safeAreaLayoutGuide.bottomAnchor 而不是 BottomLayoutGuide.topAnchor?

转载 作者:行者123 更新时间:2023-11-30 10:43:28 25 4
gpt4 key购买 nike

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

 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)

最佳答案

使用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)
}

关于swift - iOS 11.0 中已弃用“bottomLayoutGuide” : Use view. safeAreaLayoutGuide.bottomAnchor 而不是 BottomLayoutGuide.topAnchor?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56312076/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com