Skip to content

Instantly share code, notes, and snippets.

@rdelrosario
Created December 5, 2017 21:14
Show Gist options
  • Save rdelrosario/50fb790115ff4e9f5a58b738755c0080 to your computer and use it in GitHub Desktop.
Save rdelrosario/50fb790115ff4e9f5a58b738755c0080 to your computer and use it in GitHub Desktop.
iOS Bar Setup
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
SetupNavBar(NavigationController.NavigationBar.Bounds.Size);
SetTitlePosition(CustomNavigationPage.GetTitlePosition(Element), CustomNavigationPage.GetTitlePadding(Element), CustomNavigationPage.GetTitleMargin(Element), new CGRect(0, 0, Math.Max(subtitleLabel.IntrinsicContentSize.Width, titleLabel.IntrinsicContentSize.Width), (titleLabel.IntrinsicContentSize.Height + subtitleLabel.IntrinsicContentSize.Height + (subtitleLabel.IntrinsicContentSize.Height > 0.0f ? 3.0f : 0.0f))));
System.Diagnostics.Debug.WriteLine("Preparing");
}
public override void ViewDidLayoutSubviews()
{
base.ViewDidLayoutSubviews();
if(lastNavBarWidth != NavigationController?.NavigationBar?.Bounds.Size.Width || lastNavBarHeight != NavigationController?.NavigationBar?.Bounds.Size.Height)
{
lastNavBarHeight = NavigationController?.NavigationBar?.Bounds.Size.Height ?? 0.0f;
lastNavBarWidth = NavigationController?.NavigationBar?.Bounds.Size.Width ?? 0.0f;
SetupNavBar(new CGSize(lastNavBarWidth, lastNavBarHeight));
}
SetTitlePosition( CustomNavigationPage.GetTitlePosition(Element), CustomNavigationPage.GetTitlePadding(Element),CustomNavigationPage.GetTitleMargin(Element), new CGRect(0, 0, Math.Max(subtitleLabel.IntrinsicContentSize.Width, titleLabel.IntrinsicContentSize.Width), (titleLabel.IntrinsicContentSize.Height + subtitleLabel.IntrinsicContentSize.Height + (subtitleLabel.IntrinsicContentSize.Height > 0.0f ? 3.0f : 0.0f))));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment