Issue
As shown here we can leave space for the iOS status bar by using SetUseSafeArea
.
But is there something similar for a Xamarin.iOS app that is not a Xamarin.Forms app?
Solution
First, you can refer to safeAreaLayoutGuide from Apple document, then there is another similar discussion about navitve iOS how to achieve that, you also can refer to do the same in Xamarin.iOS.
Here is the Xamarin.iOS sample code for reference:
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();
}
Answered By - Junior Jiang
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.