我已經調整一個的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