还可以通过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];