Ability to hide Shell separator on iOS #32011
Unanswered
AncientLust
asked this question in
Ideas
Replies: 1 comment
-
|
I ended up using this solution:
using Microsoft.Maui.Controls.Handlers.Compatibility;
using Microsoft.Maui.Controls.Platform.Compatibility;
using UIKit;
namespace YourApp.Platforms.iOS
{
public class CustomAppShell : ShellRenderer
{
protected override IShellTabBarAppearanceTracker CreateTabBarAppearanceTracker()
{
return new MyBottomNavViewAppearanceTracker();
}
protected override IShellNavBarAppearanceTracker CreateNavBarAppearanceTracker()
{
return new NoLineAppearanceTracker();
}
}
public class NoLineAppearanceTracker : IShellNavBarAppearanceTracker
{
public void Dispose() { }
public void ResetAppearance(UINavigationController controller) { }
public void SetAppearance(UINavigationController controller, ShellAppearance appearance)
{
var navBar = controller.NavigationBar;
var navigationBarAppearance = new UINavigationBarAppearance();
navigationBarAppearance.ConfigureWithOpaqueBackground();
if (appearance.BackgroundColor != null)
{
var color = appearance.BackgroundColor;
navigationBarAppearance.BackgroundColor = UIColor.FromRGBA(
color.Red,
color.Green,
color.Blue,
color.Alpha);
}
else
{
navigationBarAppearance.BackgroundColor = UIColor.Clear;
}
if (appearance.ForegroundColor != null)
{
var fgColor = appearance.ForegroundColor;
var uiFgColor = UIColor.FromRGBA(
fgColor.Red,
fgColor.Green,
fgColor.Blue,
fgColor.Alpha);
navigationBarAppearance.TitleTextAttributes = new UIStringAttributes
{
ForegroundColor = uiFgColor
};
navBar.TintColor = uiFgColor;
}
navigationBarAppearance.ShadowColor = UIColor.Clear;
navBar.ScrollEdgeAppearance = navBar.StandardAppearance = navigationBarAppearance;
}
public void SetHasShadow(UINavigationController controller, bool hasShadow) { }
public void UpdateLayout(UINavigationController controller) { }
}
class MyBottomNavViewAppearanceTracker : IShellTabBarAppearanceTracker
{
public void Dispose() { }
public void ResetAppearance(UITabBarController controller) { }
public void UpdateLayout(UITabBarController controller) { }
public void SetAppearance(UITabBarController controller, ShellAppearance appearance)
{
var tabBar = controller.TabBar;
var tabBarAppearance = new UITabBarAppearance();
tabBarAppearance.ConfigureWithTransparentBackground();
tabBarAppearance.ShadowColor = UIColor.Clear;
if (appearance.BackgroundColor != null)
{
var color = appearance.BackgroundColor;
tabBarAppearance.BackgroundColor = UIColor.FromRGBA(
color.Red,
color.Green,
color.Blue,
color.Alpha);
}
else
{
tabBarAppearance.BackgroundColor = UIColor.Clear;
}
tabBar.ScrollEdgeAppearance = tabBar.StandardAppearance = tabBarAppearance;
}
}
}Addition for // Remove shell separator
builder.ConfigureMauiHandlers(handlers =>
{
handlers.AddHandler(typeof(Shell), typeof(Platforms.iOS.CustomAppShell));
});It doesn't have:
The only downside: the separator will disappear on all your pages. It still would be convenient to have |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently shell has gray separator on iOS:
And Android doesn't:
Docs show that switch exists for NavigationPage, but there is no solution for Shell:
It can be disabled on iOS via this solution, but it will brake two other things. Fixing of those brakes other, etc.
Is it that hard to add
Shell.HideNavigationBarSeparatorfield to ContentPage?Beta Was this translation helpful? Give feedback.
All reactions