相关疑难解决方法(0)

iOS更改导航栏标题字体和颜色

所以我有这个代码应该更改导航栏标题字体,但它是doenst

    NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont
                                                                       fontWithName:_dataManager.optionsSettings.fontString size:14], NSFontAttributeName,
                            [UIColor whiteColor], NSForegroundColorAttributeName, nil];

[[UINavigationBar appearance] setTitleTextAttributes:attributes];
Run Code Online (Sandbox Code Playgroud)

使用此代码更改后退按钮字体可以正常工作.

   //set backbutton font
NSDictionary *normalAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
                                  [UIFont fontWithName:_dataManager.optionsSettings.fontString size:15], NSFontAttributeName,
                                  nil];
[[UIBarButtonItem appearance] setTitleTextAttributes:normalAttributes
                                            forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)

fonts navigationbar ios ios7

99
推荐指数
6
解决办法
10万
查看次数

如何更改导航栏后退按钮的字体?

如何更改导航栏的后退按钮的字体.

后退按钮是"后退"或前一个视图控制器的标题.

我认为这viewDidLoad会奏效:

navigationController?.navigationItem.leftBarButtonItem?.setTitleTextAttributes([NSFontAttributeName: UIFont(name: "FONTNAME", size: 20)!], forState: UIControlState.Normal)
Run Code Online (Sandbox Code Playgroud)

但是leftBarButton?可选的退货nil.

cocoa-touch uinavigationbar uinavigationcontroller ios swift

36
推荐指数
4
解决办法
4万
查看次数

更改导航栏按钮字体

我在我的AppDelegate.m上有这个:

// Change the appearance of back button
UIImage *backButtonImage = [[UIImage imageNamed:@"back"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 20, 0, 0)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setFont:[UIFont fontWithName:@"Raleway-ExtraLight" size:18]];
Run Code Online (Sandbox Code Playgroud)

构建成功但是当它在我的iPod上运行时,它在调试控制台上给我这个错误消息:

2013-09-10 16:42:19.581 PushTransition[3599:907] -[_UIBarItemAppearance setFont:]: unrecognized selector sent to instance 0x1cda7100
2013-09-10 16:42:19.586 PushTransition[3599:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_UIBarItemAppearance setFont:]: unrecognized selector sent to instance 0x1cda7100'
*** First throw call stack:
(0x333602a3 0x3b04497f 0x33363e07 0x33362531 0x332b9f68 0x4ff27 0x351c8ad9 0x351c8663 0x351c084b 0x35168c39 0x351686cd 0x3516811b 0x36e6f5a3 0x36e6f1d3 0x33335173 0x33335117 …
Run Code Online (Sandbox Code Playgroud)

objective-c ios

2
推荐指数
1
解决办法
1490
查看次数