我一直在寻找一种方法来改变navigationBar中的标题字体,并在下面尝试但没有任何反应,字体在UILabel上工作正常等等。
UINavigationBar.appearance().titleTextAttributes = [
NSFontAttributeName: UIFont(name: "SourceSansPro-Regular", size: 18) ?? UIFont.systemFontOfSize(18)
]
答案 0 :(得分:0)
[[UINavigationBar appearance] setTitleTextAttributes:@{
UITextAttributeTextColor : [UIColor whiteColor],
UITextAttributeTextShadowColor : [UIColor blackColor],
UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetMake(1, 0)],
UITextAttributeFont : [UIFont fontWithName:@"System" size:25.0]
}];
in swift
UINavigationBar.appearance().titleTextAttributes = [UITextAttributeTextColor: UIColor.whiteColor(),
UITextAttributeTextShadowColor: UIColor.blackColor(),
UITextAttributeTextShadowOffset: NSValue(UIOffset: UIOffsetMake(1, 0)),
UITextAttributeFont: UIFont(name: "System", size: 25.0)]