更改导航栏系统uibarButtonItem颜色

时间:2013-07-16 07:23:11

标签: ios cocoa-touch uinavigationbar uiappearance

我想用iOS 7风格创建iOS 6应用程序..

到目前为止我可以实现它,最后一个问题是NavigationBarItem动作按钮,颜色是白色。

enter image description here

如何通过在AppDelegate.m

中添加几行来更改文本的背景和颜色
UIImage *backButtonImage = [UIImage imageNamed:@"button_back.png"];
    [[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    [[UIBarButtonItem appearance] setBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

[[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                      [UIColor colorWithRed:(21/255.0) green:(125/255.0) blue:(251/255.0) alpha:1],
                                                      UITextAttributeTextColor,
                                                      [UIColor clearColor],
                                                      UITextAttributeTextShadowColor,
                                                      [NSValue valueWithUIOffset:UIOffsetMake(0, -1)],
                                                      UITextAttributeTextShadowOffset,
                                                      [UIFont fontWithName:@"Helvetica Neue" size:17.0],
                                                      UITextAttributeFont,
                                                      nil] forState:UIControlStateNormal];

button_back.png实际上是空白图片。我想让背景空白。

0 个答案:

没有答案