Set opacity of UINavigationBar using UIAppearance in iOS5?

Discussion in 'iOS Programming' started by moonman239, Jun 20, 2012.

  1. moonman239 macrumors 68000

    Mar 27, 2009
    I want to know how to make the UINavigationBar translucent.
    [[UINavigationBar appearance] setOpaque:FALSE];
    caused an exception to be thrown, which caused the app to be terminated. I'm also using a background image. I suppose I'll need a translucent image as well.

    Thanks for your help!
  2. chown33 macrumors 604

    Aug 9, 2009
    Please post the exception's stack dump (symbolicated).
  3. idelovski macrumors regular

    Sep 11, 2008
    Instead of opaque I think you should use translucent property.

    I know that all the things I do on the navigation bars come down to these properties: -barStyle, -translucent and -alpha.
  4. moonman239 thread starter macrumors 68000

    Mar 27, 2009
    Here's the output after trying what idelovski suggested:

    2012-06-21 09:56:56.602 CleanCuisine[4692:10103] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** Illegal property type, c in invocation selector, _UIAppearance_setTranslucent:'
    *** First throw call stack:
    (0x1870d72 0x1067e51 0x1870b4b 0x43d060 0x438cdc 0x4390d5 0x5c658 0x90042 0x5cb77 0x581cb 0x5e482 0x56ad2 0x4231d 0x424f6 0x4268c 0x4a871 0x11a90 0x1296a 0x232be 0x23f9f 0x163fd 0x17cdf39 0x17cdc10 0x17e6da5 0x17e6b12 0x1817b46 0x1816ed4 0x1816dab 0x1228f 0x13e71 0x1ddd 0x1d05)
    libc++abi.dylib: terminate called throwing an exception
  5. moonman239 thread starter macrumors 68000

    Mar 27, 2009
    Update: I tried putting the following code into ViewController.m, but to no avail.

    self.navigationController.navigationBar.translucent = YES;
    Xcode throws no errors, but it just doesn't work.

    Edit: Should the image be translucent?

    I have to wonder: Why does Xcode make a seemingly simple task as hard as it is? I shouldn't have to touch the code just to do this! I should be able to do it in the GUI editor! :mad:
  6. idelovski, Jun 21, 2012
    Last edited: Jun 21, 2012

    idelovski macrumors regular

    Sep 11, 2008
    Then it looks a s if the translucent property is just the flag Apple uses when they draw their image or whatever they do to draw the bar. In your case, you need to supply such image or use alpha property. Try .66f for alpha or something like that.


    And subviews are laid out differently if navbar is translucent. TableViews scroll cells under the navbar if it's translucent (and under status bar too if it is translucent).

Share This Page