UIBarButtonItem在按下后更改字体,在外观代理中指定

kok*_*oko 5 xcode uibarbuttonitem ios ios7

我在AppDelegate中UIBarButtonItem通过appearance代理设置标题字体:

[[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                      [UIFont fontWithName:@"Segoe Print" size: 14.0], UITextAttributeFont,
                                                      DEF_TITLE_COLOR,UITextAttributeTextColor,
                                                      [UIColor colorWithRed:100/255 green:128/255 blue:43/255 alpha:0.4], UITextAttributeTextShadowColor,
                                                      [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset, nil]
                                            forState:UIControlStateNormal&UIControlStateHighlighted&UIControlStateDisabled];
Run Code Online (Sandbox Code Playgroud)

之后我presentViewController::在我的应用程序的某个地方打电话.条形按钮显示正确的字体和背景图像,我在此ViewController中设置(不通过外观):

在此输入图像描述

但是当我按下"加入"按钮时,会显示标准的非自定义UIAlertView,并且在它出现在屏幕上之后我的barButton字体变为...标准?颜色也看起来像色彩.我不知道我做错了什么,尝试了很多东西来解决它:

在此输入图像描述

此错误仅出现在iOS7上.

kok*_*oko 1

好吧,我发现外观代理并没有像我预期的那样工作。我将自定义方法复制粘贴到初始化的位置之前UIBarButtonItem,并且它发挥了作用。