cuốn sách gpt4 ai đã làm

ios - 为最新的 iOS 转换 bottomLayoutGuide,safeAreaLayoutGuide

In lại Tác giả: Walker 123 更新时间:2023-11-28 20:51:44 hai mươi bốn 4
mua khóa gpt4 Nike

如果你有类似的东西

something = bottomLayoutGuide.length

现在你只是得到一个警告

'bottomLayoutGuide' was deprecated in iOS 11.0: Use view.safeAreaLayoutGuide
.bottomAnchor instead of bottomLayoutGuide.topAnchor

我不知道该怎么做。我只是不知道如何从 .safeAreaLayoutGuide 中获取值

我想我最好在尝试了大约 20 次之后放弃并在这里提问。

câu trả lời hay nhất

顶部和底部布局指南 是当前 UIViewController 的一部分。在 iOS 11 上,它们被 SafeLayoutGuide 取代,后者是 UIViewController Root View 的一部分。

từApple's Documentation :

When the view is visible onscreen, this guide reflects the portion of the view that is not covered by navigation bars, tab bars, toolbars, and other ancestor views. (In tvOS, the safe area reflects the area not covered the screen's bezel.) If the view is not currently installed in a view hierarchy, or is not yet visible onscreen, the layout guide edges are equal to the edges of the view.

您需要从 safeAreaInsets 中获取它SafeLayoutGuide

的属性

所以,而不是这个:

something = bottomLayoutGuide.length

你可以使用这个:

something = view.safeAreaInsets.bottom

关于ios - 为最新的 iOS 转换 bottomLayoutGuide,safeAreaLayoutGuide,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57777717/

hai mươi bốn 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress