UIBarButtonItem changes font after being pressed, specified in appearance proxy

大兔子大兔子 提交于 2019-12-10 14:37:44

问题


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

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):

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:

This bug appears only on iOS7.


回答1:


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.




回答2:


This may work in case of iOS 7 :

In viewDidLoad method:

[self.navigationController.navigationBar setBarTintColor:[UIColor whiteColor]];

and set Font properties as well.



来源:https://stackoverflow.com/questions/18935574/uibarbuttonitem-changes-font-after-being-pressed-specified-in-appearance-proxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!