[英]UIBarButtonItem: how can I change the text shadow offset?
我正在尝试更改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];
更改文本颜色即可。 更改阴影颜色有效。 更改阴影偏移似乎没有任何作用。
我这样做的方式有问题吗? 我也尝试过直接设置它,没有外观代理,但这也不起作用。
我相信您的代码是正确的,尽管也许您期望与它有所不同。 如果我将其粘贴到测试应用程序中并将偏移值更改为10.0、10.0,则阴影偏移对我可见。 (iOS 5.0)
您的阴影UIOffset值为0.0,0.0,实际上不会产生阴影。 您将需要在任何方向上将阴影至少偏移1个像素。 例如。 这会在左侧底部留下阴影。
[NSValue valueWithUIOffset:UIOffsetMake(-1.0, 1.0)]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.