gpt4 book ai didi

ios - Swift:调整 iPad 屏幕导航栏的大小

转载 作者:行者123 更新时间:2023-11-30 11:31:55 25 4
gpt4 key购买 nike

我有一个导航栏,在 iPhone 设备上看起来很完美,但在 iPad 中打开时,它显得非常小。我正在使用 Storyboard 进行设计,如何调整导航栏的大小及其 iPad 的字体。

enter image description here

最佳答案

导航栏的高度固定为 65,状态栏也固定。但如果您想更改导航栏的高度,您可以采用以下替代方法。

let height: CGFloat = 50 //whatever height you want to add to the existing height
let bounds = self.navigationController!.navigationBar.bounds
self.navigationController?.navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height + height)

以及设置字体。

if (UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad)
{
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName :NavigationColor,
NSFontAttributeName: FontLight_40
]
UIBarButtonItem.appearance().setTitleTextAttributes([NSFontAttributeName:FontLight_40], for: UIControlState.normal)
}
else
{
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName :NavigationColor,
NSFontAttributeName: FontLight_20
]
UIBarButtonItem.appearance().setTitleTextAttributes([NSFontAttributeName:FontLight_20], for: UIControlState.normal)
}

关于ios - Swift:调整 iPad 屏幕导航栏的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50168226/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com