ios - Swift:为 iPad 屏幕调整 NavigationBar 的大小
解决方案
导航栏的高度与状态栏固定为 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)
}
推荐阅读
- django-rest-framework - Django-rest-framework filter_queryset() 接受 3 个位置参数,但给出了 4 个
- node.js - 我的随机图像机器人尝试从主文件夹而不是指定文件夹中提取图像
- javascript - 在 Asp.Net C# 中使用 javascript 拆分多行文本框值
- javascript - 如何计算 Javascript 中图像的点击次数?
- algorithm - 具有 n 变量和范围的解决方案丢番图方程
- python - 为什么这个语句在 python 3.0 中是错误的?
- android - Android Studio 4.1调试断点不起作用
- wordpress - 在 Woocommerce 中隐藏特定类别档案中的缺货产品
- azure-storage - Azure 存储帐户(经典)- 仅使用帐户名称访问?
- python - 如何用python提取excel中的上标或下标数据?