using image or tint color on uinavigationbar in iphone?

前端 未结 7 1801
自闭症患者
自闭症患者 2020-12-24 09:58

how do i show a background image on a navigation bar or give tint color to the navigation bar in a native iphone application??

7条回答
  •  情深已故
    2020-12-24 10:33

    For the iOS5 and iOS6 I've used this solutions and it worked perfectly, Making a Universal UINavigationBar Background Image.

    iPhone Retina Portrait 640px x 88px / iPhone Non-Retina Portrait 320px x 44px

    Inside AppDelegate.m

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    

    Place this code

    // Set the status bar to black color.
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque animated:NO];
    
    // Change @"menubar.png" to the file name of your image.
    UIImage *navBar = [UIImage imageNamed:@"menubar.png"];
    
    [[UINavigationBar appearance] setBackgroundImage:navBar forBarMetrics:UIBarMetricsDefault];
    

    Don't forget to change the image name (menubar.png)

    Check out this link for the full answer http://www.lwxted.com/blog/2012/add-custom-background-image-uinavigationbar-ios-5/

提交回复
热议问题