Skip to content

[iOS] Shell doesn’t expose an easy way to enable large titles + translucent navbar #32917

@paulober

Description

@paulober

Description

Currently this is only possible with ios: for NavigationPages but not Shell Apps which require a custom solution. I thought my solution could be upstreamed and made available as little helper for shell apps.

public class CustomAppShell : ShellRenderer
{
    protected override IShellNavBarAppearanceTracker CreateNavBarAppearanceTracker()
    {
        return new LargeTitleNavBarAppearanceTracker();
    }
}
public class LargeTitleNavBarAppearanceTracker : IShellNavBarAppearanceTracker
{
    public void Dispose() { }

    public void ResetAppearance(UINavigationController controller) { }

    public void SetAppearance(UINavigationController controller, ShellAppearance appearance)
    {
        var navBar = controller.NavigationBar;

        // Big titles
        navBar.PrefersLargeTitles = true;

        // Translucent / no separator line
        var navBarAppearance = new UINavigationBarAppearance();
        navBarAppearance.ConfigureWithTransparentBackground();
        navBarAppearance.BackgroundColor = UIColor.Clear;
        navBarAppearance.ShadowColor = UIColor.Clear;   // remove bottom hairline
        navBarAppearance.BackgroundEffect = null;

        // Respect Shell colors if used
        if (appearance?.ForegroundColor is not null)
        {
            var fg = appearance.ForegroundColor;
            var uiFg = UIColor.FromRGBA((nfloat)fg.Red, (nfloat)fg.Green, (nfloat)fg.Blue, (nfloat)fg.Alpha);

            navBarAppearance.TitleTextAttributes = new UIStringAttributes { ForegroundColor = uiFg };
            navBarAppearance.LargeTitleTextAttributes = new UIStringAttributes { ForegroundColor = uiFg };
        }

        navBar.StandardAppearance = navBarAppearance;
        navBar.ScrollEdgeAppearance = navBarAppearance;

        // Force large titles on the current VC without touching ContentPages
        if (controller.TopViewController is { } vc)
            vc.NavigationItem.LargeTitleDisplayMode = UINavigationItemLargeTitleDisplayMode.Always;
    }

    public void UpdateLayout(UINavigationController controller) { }

    public void SetHasShadow(UINavigationController controller, bool hasShadow)
    {
        // we already removed shadow via ShadowColor = Clear
        // so ignore
    }
}

I will try to create a PR for this but feedback on how to best integrate this are very Wellcome.

Public API Changes

<Shell
  xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
  ios:Shell.PrefersLargeTitles="true"
  ios:Shell.IsNavigationBarTranslucent="true">

Intended Use-Case

To create more native looking apps for iOS 26. Apple now uses this still in many of their current apps like the Sports app.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions