1

I have a navigation bar that looks like so:

enter image description here

It was created with the following code:

//  AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{    
    NSShadow *textShadow = [[NSShadow alloc] init];
    textShadow.shadowBlurRadius = 5.0;
    textShadow.shadowColor = [UIColor colorWithWhite: 1.0 alpha: 0.75];
    textShadow.shadowOffset = CGSizeMake(0.0, 1.0);
    [[UIBarButtonItem appearance] setTitleTextAttributes: @{ NSShadowAttributeName: textShadow } forState: UIControlStateNormal];

    return YES;
}

Questions

  1. Where is the shadowBlurRadius (at least for the "Edit" button)? Notice that I set textShadow.shadowBlurRadius = 5.0;. Cranking up that value doesn't seem to do anything either.
  2. Is it possible to add a shadow to the "+" bar button item or other bar button items that are not text (e.g. UIBarButtonSystemItemCamera)? I'd like to avoid generating my own rasterized images.

This question pertains to iOS 7 only.

JWK
  • 3,345
  • 2
  • 19
  • 27
  • Have you ever fixed this? I've just hit the same problem. I can't seem to make `shadowBlurRadius` do anything... – Mihai Fratu Jun 17 '15 at 19:17

1 Answers1

1

Actually your shadow is getting rendered on UIBarButonItem & you can see the white shadow in the "Edit" bar button item text. If you want to use better shadow appearance then please try to play with values in CGSizeMake here within range of -1, 1, 0

textShadow.shadowOffset = CGSizeMake(0.0, -1.0);

A bit tricky, but to add shadow to the right bar button item, please make a UIBarButton with title on it as + & assign it to the rightBarButton of navigation Item & you will get the shadow affect as you see in the left bar button item.

Hopw that helps.

Balram Tiwari
  • 5,657
  • 2
  • 23
  • 41
  • Balram, thanks for taking the time to answer my questions. That said, the first question was not about the shadow being rendered on the "Edit" button. I'm not blind ;) The question is about not seeing the shadowBlurRadius. Modifying the offset is not going to help with that. The "+" character isn't really relevant to #2 either, as I might ask the same question of a different button style that isn't text (e.g. UIBarButtonSystemItemCamera). – JWK Dec 07 '13 at 21:03
  • 1
    Also not seeing the shadowBlurRadius do anything at all. – Shaun Budhram Sep 27 '14 at 04:41