Skip to content

Commit de0119a

Browse files
committed
- switch to set needslayout and force height to always be > 36
1 parent 5c72dd8 commit de0119a

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

src/Controls/src/Core/TitleBar/TitleBar.iOS.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ internal override void OnIsVisibleChanged(bool oldValue, bool newValue)
1515
&& platWindow.RootViewController is WindowViewController windowViewController)
1616
{
1717
windowViewController.SetTitleBarVisibility(newValue);
18-
windowViewController.LayoutTitleBar();
18+
windowViewController.View?.SetNeedsLayout();
1919
}
2020
#endif
2121
}

src/Core/src/Platform/iOS/WindowViewController.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,13 @@ public void SetUpTitleBar(IWindow window, IMauiContext mauiContext, bool isInita
7979
if (newTitleBar != iTitleBar)
8080
{
8181
_titleBar?.RemoveFromSuperview();
82+
iTitleBar?.DisconnectHandlers();
8283
iTitleBar = null;
8384

8485
if (newTitleBar is not null)
8586
{
8687
iTitleBar = window.TitleBar;
88+
SetTitleBarVisibility(iTitleBar?.Visibility == Visibility.Visible);
8789
View.AddSubview(newTitleBar);
8890
}
8991

@@ -99,13 +101,15 @@ public void SetUpTitleBar(IWindow window, IMauiContext mauiContext, bool isInita
99101
platformTitleBar.TitleVisibility = UITitlebarTitleVisibility.Hidden;
100102
}
101103

102-
LayoutTitleBar();
103-
104104
// When we are initializing, calling LayoutIfNeeded will cause the layout events to not fire properly.
105105
// However we need this when the titlebar is added or removed or the titlebar may not be fully laid out.
106106
if (!isInitalizing)
107107
{
108-
View.LayoutIfNeeded();
108+
View?.SetNeedsLayout();
109+
}
110+
else
111+
{
112+
LayoutTitleBar();
109113
}
110114
}
111115

@@ -126,7 +130,11 @@ public void LayoutTitleBar()
126130

127131
if (!_isTitleBarVisible)
128132
{
129-
titleBarHeight = 0;
133+
titleBarHeight = 36;
134+
}
135+
else if (titleBarHeight < 36)
136+
{
137+
titleBarHeight = 36;
130138
}
131139

132140
var newFrame = new CGRect(0, titleBarHeight, View!.Bounds.Width, View!.Bounds.Height - titleBarHeight);

0 commit comments

Comments
 (0)