简而言之,当添加工具栏时,它会适当地更改窗口的样式,将三个按钮隔开。如何在不添加工具栏的情况下实现相同的效果?
我不能使用空工具栏,因为最终目标是创建一个外观完全不同的工具栏。
Unfortunately, since I'm using a Mac Catalyst app I can't customize the toolbar
但出于美观的原因,我仍然需要它看起来像一个工具栏。
“Notability”是官方推出的一款流行的笔记应用程序
WWDC2021 video
也有同样的问题。
在Mac Catalyst版本的Notability中没有工具栏。标题栏是隐藏的。内容被稍微移到底部以创建更多空间,自定义视图被放置在上面,使其看起来像工具栏。
左边是它的样子。右边是它应该是什么样子(我对它进行了PS处理)以及我试图实现的目标。不修复它并保持这种方式是非常容易的,因为隐藏标题栏可能需要几行代码:
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
#if TARGET_OS_MACCATALYST
// Code specific to Mac.
[(UIWindowScene*)scene titlebar].separatorStyle = UITitlebarSeparatorStyleNone;
[(UIWindowScene*)scene titlebar].titleVisibility = UITitlebarTitleVisibilityHidden;
#else
// Code to exclude from Mac.
#endif
}
我有没有机会通过使用从不拆分的拆分视图或其他UI元素或设置隐藏或不隐藏来破解它?