Ios 消除uibarbuttonim';s文本阴影
我已经调整了一个uibarbuttonite,使用Ios 消除uibarbuttonim';s文本阴影,ios,objective-c,uibarbuttonitem,Ios,Objective C,Uibarbuttonitem,我已经调整了一个uibarbuttonite,使用 self.followButton = [[[UIBarButtonItem alloc] initWithTitle: NSLocalizedString(@"TWITTER_FOLLOW_BUTTON_TEXT", nil) style:UIBarButtonItemStylePlain
self.followButton = [[[UIBarButtonItem alloc]
initWithTitle: NSLocalizedString(@"TWITTER_FOLLOW_BUTTON_TEXT", nil)
style:UIBarButtonItemStylePlain
target:self
action:@selector(handleFollowButtonPressed:)]
autorelease];
,
,
及
出现
如何删除buttonitem的文本阴影而不改变图像 将
UIBarButtonItem
的uitexttributetextshadowoffset
属性设置为UIOffsetMake(0.0,0.0)
您需要将
UIOffset
存储在NSValue
对象中:[NSValue-valueWithUIOffset:UIOffsetMake(0.0,0.0)]
或者您可以将uitexttributetextshadowcolor设置为[UIColor clearColor]
@{UITextAttributeTextShadowColor : [UIColor clearColor]}
非常感谢。所以我想我应该使用[followButton setTitleTextAttributes:[NSDictionary Dictionary With Objects and Keys:[UIFont FontWith Name:@“Helvetica”大小:14.0]、UITextAttributeForent、[NSValue ValueWith CGSize:CGSizeMake(0.0,0.0)]、UITextAttributeExtShadowOffset,nil]来表示状态:UIControlStateNormal];不是第一部分,但它没有改变它,怎么了?根据
uitexttributetextshadowoffset
的文档,在NSValue
中包装的值应该是UIOffset
,而不是CGSize
。因此,您需要使用[NSValue-valueWithUIOffset:UIOffsetMake(0,0)]
。
[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];
@{UITextAttributeTextShadowColor : [UIColor clearColor]}