Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing UIBarButtonItem's text shadow

I have adjusted a UIBarButtonItem to have custom font and color properties using

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];  

and

NSDictionary *attributes = @{UITextAttributeTextColor : [UIColor colorWithRed:1 green:0.176 blue:0.333 alpha:1 /*#ff2d55*/ ]};

    [followButton setTitleTextAttributes:attributes
                            forState:UIControlStateNormal]; 

to get the appearance of

enter image description here

How can I remove the buttonitem's text shadow without resorting to changing it for an image?

like image 971
Peter V Avatar asked Jun 30 '26 22:06

Peter V


1 Answers

Set the UIBarButtonItem's UITextAttributeTextShadowOffset attribute to UIOffsetMake(0.0, 0.0).

You'll need to store the UIOffset in an NSValue object: [NSValue valueWithUIOffset: UIOffsetMake(0.0, 0.0)].

like image 160
Vinny Coyne Avatar answered Jul 02 '26 12:07

Vinny Coyne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!