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)

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


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

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