UIBarButtonItem在按下后更改字体,在外观代理中指定 [英] UIBarButtonItem changes font after being pressed, specified in appearance proxy

查看:125
本文介绍了UIBarButtonItem在按下后更改字体,在外观代理中指定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I set up UIBarButtonItem title font through appearance proxy in AppDelegate:

[[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];

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

And after that I am calling presentViewController:: in some place of my app. Bar button is shown with proper font and background image, which I set up in this ViewController (not through appearance):

但是当我按下加入按钮时,会显示标准的非自定义UIAlertView ,它出现在屏幕上后,我的barButton字体变为......标准?颜色也看起来像淡色。我不知道我做错了什么,尝试了大量的事情来解决这个问题:

But when I press "Join" button, standard non-customized UIAlertView is shown, and right after it appears on the screen my barButton font changes to ... standard? And color also looks like tint color. I have no Idea what I am doing wrong, tried loads of things to figure it out:

此错误仅出现在iOS7上。

This bug appears only on iOS7.

推荐答案

好吧,我认为外观代理不能像我预期的那样工作。我在初始化 UIBarButtonItem 的地方之前复制粘贴的自定义方法,并且它作为魅力。

Well, I've figured that apperance proxy doesn't work as I expected. I copy-pasted customization method right before a place where UIBarButtonItem is initialized, and it worked as charm.

这篇关于UIBarButtonItem在按下后更改字体,在外观代理中指定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆