UIBarButtonItem:如何更改文本阴影偏移量?

Ste*_*ghe 8 cocoa-touch uibarbuttonitem ios

我正试图改变文本背后阴影的偏移量UIBarButtonItem.

这是我的代码:

NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
[attributes setValue:[UIColor colorWithWhite:0.30 alpha:1.0] forKey:UITextAttributeTextColor];
[attributes setValue:[UIColor whiteColor] forKey:UITextAttributeTextShadowColor];
[attributes setValue:[NSValue valueWithUIOffset:UIOffsetMake(0.0, 0.0)] forKey:UITextAttributeTextShadowOffset];
[[UIBarButtonItem appearance] setTitleTextAttributes:attributes forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)

更改文本颜色有效.更改阴影颜色有效.更改阴影偏移似乎没有任何作用.

我这样做的方式有问题吗?我也试过直接设置它,没有外观代理,但这也不起作用.

Phi*_*lls 1

我相信您的代码是正确的,尽管您可能期望与它所做的有所不同。如果我将其粘贴到测试应用程序中并将偏移值更改为 10.0, 10.0,阴影偏移对我来说是可见的。(iOS 5.0)

这是运行您发布的内容时从模拟器中截取的剪辑。