我已使用
调整了UIBarButtonItem以使用自定义字体和颜色属性self.followButton = [[[UIBarButtonItem alloc]
initWithTitle: NSLocalizedString(@"TWITTER_FOLLOW_BUTTON_TEXT", nil)
style:UIBarButtonItemStylePlain
target:self
action:@selector(handleFollowButtonPressed:)]
autorelease];
,
[self.followButton setBackgroundImage:[UIImage new] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
,
[followButton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIFont fontWithName:@"Helvetica" size:14.0], UITextAttributeFont,nil] forState:UIControlStateNormal];
和
NSDictionary *attributes = @{UITextAttributeTextColor : [UIColor colorWithRed:1 green:0.176 blue:0.333 alpha:1 /*#ff2d55*/ ]};
[followButton setTitleTextAttributes:attributes
forState:UIControlStateNormal];
获得
的外观
如何删除buttonitem的文本阴影,而无需更改图像?
答案 0 :(得分:6)
将UIBarButtonItem
的{{1}}属性设置为UITextAttributeTextShadowOffset
。
您需要将UIOffsetMake(0.0, 0.0)
存储在UIOffset
对象中:NSValue
。
答案 1 :(得分:3)
或者你可以将UITextAttributeTextShadowColor设置为[UIColor clearColor]
@{UITextAttributeTextShadowColor : [UIColor clearColor]}