还可以通过titleTextAttriutes属性定制UIBarButton。setTitleTextAttributes:方法用一个NSDictionary参数指定所需选项:
UITextAttributeTextColor,定制文字颜色。
UITextAttributeTextShadowColor,定制文字的阴影色。
UITextAttributeTextShadowOffset,定制阴影的偏移位置。
UITextAttributeFont,定制文本字体。
// Settitletext attributes
NSMutableDictionary *attributes= [[NSMutableDictionary alloc] init];
[attributessetValue:[UIColor blackColor] forKey:UITextAttributeTextColor];
[attributessetValue:[UIColor whiteColor] forKey:UITextAttributeTextShadowColor];
[attributessetValue:[NSValue valueWithUIOffset:UIOffsetMake(0, 1)]forKey:UITextAttributeTextShadowOffset];
[attributessetValue:[UIFont fontWithName:@"Verdana"size:0.0] forKey:UITextAttributeFont];
[[UIBarButtonItemappearance] setTitleTextAttributes:attributes forState:UIControlStateNormal];
[attributesrelease];
本文介绍如何使用setTitleTextAttributes方法定制UIBarButton的文字颜色、阴影色、阴影偏移位置及字体等属性,实现按钮样式的个性化。

被折叠的 条评论
为什么被折叠?



