我已经调整一个的UIBarButtonItem有自定义字体和颜色属性使用删除的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的文字阴影,而不诉诸改变它的形象?
谢谢!所以我想我应该使用 [followButton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@“Helvetica”size:14.0],UITextAttributeFont,[NSValue valueWithCGSize:CGSizeMake(0.0,0.0)],UITextAttributeTextShadowOffset,nil] forState:UIControlStateNormal] ; 而不是第一部分,但它不会改变它,有什么问题? –
根据'UITextAttributeTextShadowOffset'的文档,'NSValue'中包含的值应该是'UIOffset',而不是'CGSize'。所以你需要使用'[NSValue valueWithUIOffset:UIOffsetMake(0,0)]''。 – rmaddy