Bug 49104 - Platform-specific IsNavigationBarTranslucent does not work on iOS
Summary: Platform-specific IsNavigationBarTranslucent does not work on iOS
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 2.3.3
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-12-06 16:36 UTC by Matthew Richardson
Modified: 2017-01-12 19:45 UTC (History)
5 users (show)

See Also:
Tags:
Is this bug a regression?: Yes
Last known good build: 2.3.2


Attachments
Sample Project with IsNavigationBarTranslucent Platform Specific (44.26 KB, application/zip)
2016-12-06 16:36 UTC, Matthew Richardson
Details

Description Matthew Richardson 2016-12-06 16:36:23 UTC
Created attachment 18791 [details]
Sample Project with IsNavigationBarTranslucent Platform Specific

Attempting to set the new platform-specific used to change the transparency of the navigation bar does not work.
Either when:
- Consuming as an attached property in the XAML
- Consuming using the fluent API in code.

This issue is present in the current release of Xamarin.Forms 2.3.3.168-stable.
Please see attached sample project for a repro.

Note: Further investigation and testing using a custom NavigationPage renderer, shows that setting NavigationBar.Translucent now has no effect in XF 2.3.3. Whereas previously this worked in XF 2.3.2!
Comment 1 Matthew Richardson 2016-12-06 17:03:29 UTC
It appears this may be related to a change in PR 301.
https://github.com/xamarin/Xamarin.Forms/blob/8c56905c58fa76fa670acf781756f0da304e44a7/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs
See new line 827:
EdgesForExtendedLayout = UIRectEdge.None

Using Reveal as a view debugger shows the Translucent property is being set on the NavigationBar, but the EdgesForExtendedLayout value is preventing the view from extending its layout to fill the whole screen.
Comment 2 adrianknight89 2016-12-07 16:48:27 UTC
Can you test it in 2.3.3.175?
Comment 3 Matthew Richardson 2016-12-07 17:27:13 UTC
Thanks Adrian.

Yes, this issue is also present in 2.3.3.175.
I can confirm it is the EdgesForExtendedLayout property in the NavigationRenderer.

The following workaround fixes the problem in the ViewWillAppear() method using a custom page renderer on iOS:

public override void ViewWillAppear(bool animated)
{
    base.ViewWillAppear(animated)

    var parent = ParentViewController;
    if (parent != null)
    {
        parent.EdgesForExtendedLayout = NavigationController.NavigationBar.Translucent
            ? UIRectEdge.All
            : UIRectEdge.None;
    }
}

So, EdgesForExtendedLayout needs to be set dependent on the state of NavigationBar.Translucent.
Comment 4 Jimmy [MSFT] 2016-12-07 19:05:09 UTC
See PR: https://github.com/xamarin/Xamarin.Forms/pull/621
Comment 5 Rui Marinho 2017-01-12 19:45:23 UTC
Should be fixed in 2.3.4-pre1

Note You need to log in before you can comment on or make changes to this bug.