This is a common issue in .NET MAUI (and previously in Xamarin.Forms) on iOS, where the NavigationPage adds a default padding at the top to account for the status bar and/or the navigation bar. Even if you don't have explicit margins or padding in your XAML, the iOS platform applies this space by default.
Root Cause
On iOS, the NavigationPage uses a UINavigationController, which includes a navigation bar. The navigation bar's height (including the status bar area) is reserved, even if you hide the navigation bar or set it to transparent. This results in the blank space you're seeing.
How to Fix It
You need to override the default behavior by setting the SafeAreaInsets or adjusting the NavigationPage properties in your platform-specific code.
1. Set NavigationPage.HasNavigationBar="False"
If you don't need the navigation bar at all, you can disable it in your XAML:
<NavigationPage.HasNavigationBar="False">
<ContentPage ...>
<CollectionView ... />
</ContentPage>
</NavigationPage>
However, this might not always remove the padding entirely, especially if the status bar is still present.
2. Use Platform-Specific Code to Adjust Safe Area (Recommended)
For more control, use platform-specific code in your App.xaml.cs or a custom renderer/handler.
Option A: Set SafeAreaInsets to Zero (iOS 11+)
In your MauiProgram.cs or platform-specific code, add:
#if IOS
using Microsoft.Maui.Platform;
Microsoft.Maui.Handlers.NavigationViewHandler.Mapper.AppendToMapping("NoSafeArea", (handler, view) =>
{
if (handler.VirtualView is NavigationPage navigationPage)
{
var navigationController = handler.PlatformView as UIKit.UINavigationController;
if (navigationController != null)
{
navigationController.AdditionalSafeAreaInsets = new UIKit.UIEdgeInsets(0, 0, 0, 0);
}
}
});
#endif
Option B: Override in a Custom Handler
If the above doesn't work, create a custom handler for NavigationPage:
#if IOS
public class CustomNavigationPageHandler : NavigationViewHandler
{
protected override UIKit.UINavigationController CreatePlatformView()
{
var navigationController = base.CreatePlatformView();
navigationController.AdditionalSafeAreaInsets = new UIKit.UIEdgeInsets(0, 0, 0, 0);
return navigationController;
}
}
#endif
Then, register it in MauiProgram.cs:
builder.ConfigureMauiHandlers(handlers =>
{
#if IOS
handlers.AddHandler<NavigationPage, CustomNavigationPageHandler>();
#endif
});
3. Use Shell Instead of NavigationPage (Alternative)
If possible, consider using Shell instead of NavigationPage. Shell has better control over safe area insets and navigation bar behavior.
Summary
- The issue is caused by iOS reserving space for the navigation bar/status bar.
- Disable the navigation bar if not needed, or override the safe area insets in platform-specific code.
- For more control, use a custom handler or switch to
Shell.