Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
419 views
in Technique[技术] by (71.8m points)

c# - Xamarin.iOS Custom page renderer override PreferredStatusBarStyle is never called

I wrote a small custom Renderer for iOS that is able to change the StatusBar Text Color whenever i need it for a certain Page. The renderer is just a basic PageRenderer and according to other SO questions and the iOS docs what you should do is the following:

public override void ViewWillAppear(bool animated)
{
    base.ViewWillAppear(animated);
    //Call this method
    this.SetNeedsStatusBarAppearanceUpdate();
}

public override UIStatusBarStyle PreferredStatusBarStyle()
{
    //This should be called and you should be able to return you desired style
}

However the PreferredStatusBarStyle override method is never called. After some more research the reason for this is most certainly the fact, that my Page is wraped in a NavigationPage. There's a solution in Swift to call extensions on the NavigationControllers, like described in this SA post: link

I have no idea how an extension like this can be made in my custom renderer. If anyone has a clue I'd be happy to hear it. I couldn't find anything on that topic.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
...