如这里所示,我们可以使用SetUseSafeArea为iOS状态栏留出空间。
但是,对于不是Xamarin.iOS应用程序的Xamarin.Forms应用程序,是否有类似的东西呢?
发布于 2020-08-26 01:48:09
首先,您可以从苹果文档中引用safeAreaLayoutGuide,然后是关于navitve iOS如何实现的另一次类似的讨论,您也可以参考在Xamarin.iOS中做同样的事情。
下面是Xamarin.iOS示例代码供参考:
public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear(animated);
//suberView is your subview view in ViewController
View.Add(suberView);
suberView.TranslatesAutoresizingMaskIntoConstraints = false;
var safeGuide = View.SafeAreaLayoutGuide;
suberView.LeadingAnchor.ConstraintEqualTo(safeGuide.LeadingAnchor).Active = true;
suberView.TrailingAnchor.ConstraintEqualTo(safeGuide.TrailingAnchor).Active = true;
suberView.TopAnchor.ConstraintEqualTo(safeGuide.TopAnchor).Active = true;
suberView.BottomAnchor.ConstraintEqualTo(safeGuide.BottomAnchor).Active = true;
View.LayoutIfNeeded();
}发布于 2020-08-25 20:52:20
如果您使用的是本机,我认为UIView有一些非常类似的东西。UseSafeArea或者类似的东西。您应该能够在developer.apple.com中搜索UIView,并且它应该为您提供一些可以启用的东西。
编辑:刚刚注意到SushiHangover的评论。点击Sushi提供的链接,它将显示给您。
https://stackoverflow.com/questions/63586638
复制相似问题