[英]How to get the SafeAreaLayoutGuide for the ViewControllers of a UITabBarController?
我正在嘗試設置視圖的Anchors
,以便保持在狀態欄下方,使用:
UILayoutGuide safeGuide = view.Superview.SafeAreaLayoutGuide;
view.TranslatesAutoresizingMaskIntoConstraints = false;
view.LeadingAnchor.ConstraintEqualTo(safeGuide.LeadingAnchor).Active = true;
view.TrailingAnchor.ConstraintEqualTo(safeGuide.TrailingAnchor).Active = true;
view.TopAnchor.ConstraintEqualTo(safeGuide.TopAnchor).Active = true;
view.BottomAnchor.ConstraintEqualTo(safeGuide.BottomAnchor).Active = true;
但是我的視圖被UITabBarController
底部的選項卡部分遮擋了。
我該如何避免呢?
controller 的根視圖始終被狀態欄覆蓋。
該視圖的SafeAreaLayoutGuide
用於防止添加的子視圖擴展到狀態欄區域。
無論您使用的是UITabBarController
、 UINavigationController
、常規UIViewController
等,都是如此。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.