gpt4 book ai didi

ios - UIBarButtonItem 样式普通更改字体

转载 作者:行者123 更新时间:2023-11-29 13:02:42 25 4
gpt4 key购买 nike

改变

NSDictionary * barButtonAppearanceDict = @{UITextAttributeFont : font};
[[UIBarButtonItem appearance] setTitleTextAttributes:barButtonAppearanceDict forState:UIControlStateNormal];

使用纯...时不影响 UIBarButtonItem

如何更改普通样式 UIBarButtonItem 的字体

这仍然适用于 iOS6

最佳答案

然而,这对我有用(使用普通的 BarButtonItem),刚刚对其进行了测试:

[self.myBarButtonItem setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont fontWithName:@"Helvetica" size:22.0],NSFontAttributeName,
nil]forState:UIControlStateNormal];

要使用外观代理,您可以试试这个:

 NSDictionary *attrDict = [NSDictionary dictionaryWithObject: [UIFont fontWithName:@"Helvetica" size:22.0] forKey: UITextAttributeFont];

[[UIBarButtonItem appearance] setTitleTextAttributes: attrDict
forState: UIControlStateDisabled];
[[UIBarButtonItem appearance] setTitleTextAttributes: attrDict
forState: UIControlStateNormal];

您确定在您的 AppDelegate 类中实现了它吗? (例如在 didFinishLaunchingWithOptions 方法中)

关于ios - UIBarButtonItem 样式普通更改字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19406688/

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