MacCatalyst: Get size of title bar

Viewed 84

Good day, I'm trying to play around with the .Net 6 MacCatalyst app template and I'm having a hard time with the following: When I put any element at the top left (0, 0), the title bar will obstruct the topmost pixels as long as the application is in windowed mode, which basically looks like this: Picture of the issue.

I have searched documentation and looked around, but I could not find a way to either

  • find the height of the title bar or
  • retrieve a window frame that excludes the title bar

Is there anything I have overlooked? I know that it has to be possible because Firefox is adapting to the title bar just fine.

For this experiment I am using C# 10 with a .Net 6 "ios-maccatalyst" project

The code that demonstrates my "problem" is basically just the template code:

public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
    {
        Window = new UIWindow (UIScreen.MainScreen.Bounds);
        var vc = new UIViewController ();

        CGRect demoFrame = new CGRect(0, 0, 300, 100);

        UILabel helloLabel = new UILabel(demoFrame)
        {
            BackgroundColor = UIColor.White,
            TextAlignment = UITextAlignment.Center,
            Text = "Hello, Catalyst!",
            TextColor = UIColor.Red,
        };

        helloLabel.Layer.BorderColor = UIColor.Red.CGColor;
        helloLabel.Layer.BorderWidth = 3;

        vc.View!.AddSubview(helloLabel);
        Window.RootViewController = vc;

        Window.MakeKeyAndVisible ();

        return true;
    }
0 Answers
Related