我调整了一个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]; 获得…的外观

如何在不更改图像的情况下删除按钮项目的文本阴影?
发布于 2013-06-24 08:01:18
将UIBarButtonItem的UITextAttributeTextShadowOffset属性设置为UIOffsetMake(0.0, 0.0)。
您需要将UIOffset存储在一个NSValue对象中:[NSValue valueWithUIOffset: UIOffsetMake(0.0, 0.0)]。
发布于 2013-06-26 08:56:49
或者,您也可以将UITextAttributeTextShadowColor设置为UIColor clearColor
@{UITextAttributeTextShadowColor : [UIColor clearColor]}https://stackoverflow.com/questions/17266396
复制相似问题