iOS界面组件与模态对话框的使用与定制
1. 导航栏与标题配置
在iOS开发中,导航栏的标题配置十分重要。可以通过设置导航栏的 titleTextAttributes 来配置标题的属性字典,还能通过 titlePositionAdjustment 来调整标题的位置。对于大标题,可通过设置导航栏的 largeTitleTextAttributes 来配置其属性字典。从iOS 13开始,这些都是 UINavigationBarAppearance 的属性。例如,以下代码展示了如何配置标题:
bar.standardAppearance.titleTextAttributes = [
.font: UIFont(name:"Chalkduster", size:20)!,
.foregroundColor: UIColor.black
]
视图控制器的 navigationItem 和 UINavigationBar 一样,具有 standardAppearance 、 compactAppearance 和 scrollEdgeAppearance 属性。利用这些属性,不同的视图控制器可以根据当前导航控制器的 topViewController 来不同地配置导航栏。
超级会员免费看
订阅专栏 解锁全文
36

被折叠的 条评论
为什么被折叠?



