如何为 backBarButtonItem 设置自定义字体
How to set custom font for backBarButtonItem
当没有左侧栏项目时,导航栏会给出一个backBarButtonItem
,如<Back
。但无论如何我找不到为其设置字体。请帮我!非常感谢!
Swift:
UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font: UIFont(name: "Poppins-Regular", size: 16)!,NSAttributedString.Key.foregroundColor:.red], for: .normal)
Objective-C:
[[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName,
shadow, NSShadowAttributeName,
[UIFont fontWithName:@"Futura-Medium" size:15.0f], NSFontAttributeName, nil] forState:UIControlStateNormal];
当没有左侧栏项目时,导航栏会给出一个backBarButtonItem
,如<Back
。但无论如何我找不到为其设置字体。请帮我!非常感谢!
Swift:
UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font: UIFont(name: "Poppins-Regular", size: 16)!,NSAttributedString.Key.foregroundColor:.red], for: .normal)
Objective-C:
[[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName,
shadow, NSShadowAttributeName,
[UIFont fontWithName:@"Futura-Medium" size:15.0f], NSFontAttributeName, nil] forState:UIControlStateNormal];