2

我已经调整了 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]; 

获得外观

在此处输入图像描述

如何在不改变图像的情况下删除按钮项的文本阴影?

4

2 回答 2

6

UIBarButtonItem'UITextAttributeTextShadowOffset属性设置为UIOffsetMake(0.0, 0.0)

您需要将 存储UIOffset在一个NSValue对象中:[NSValue valueWithUIOffset: UIOffsetMake(0.0, 0.0)].

于 2013-06-24T00:01:17.737 回答
3

或者,您可以将 UITextAttributeTextShadowColor 设置为 [UIColor clearColor]

@{UITextAttributeTextShadowColor : [UIColor clearColor]}
于 2013-06-26T00:56:48.527 回答