Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7532505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:28:25+00:00 2026-05-30T05:28:25+00:00

I am trying to set the background image for UINavigationBar. I tried 2 types

  • 0

I am trying to set the background image for UINavigationBar.

I tried 2 types of methods,

 1. [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"KnavigationBarImage.png"] forBarMetrics:UIBarMetricsDefault];

It is supported in ios 5, but crashes when run it in ios 4.3.

 2. self.navigationController.navigationBar.layer.contents = (id)[UIImage imageNamed:@"KnavigationBarImage.png"].CGImage;

It is working fine in ios 4 , But the image is not displaying in ios 5 Simulator.

I need the code which should work in both version 4 and 5.

Please suggest me.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:28:27+00:00Added an answer on May 30, 2026 at 5:28 am

    Write a method like this to find which OS the device has.

    static int sIsiOS5 = -1;
    +(BOOL)isIOS5
    {
        if( -1 == sIsiOS5)
        {
            sIsiOS5 = 0;
            if( [[UIScreen mainScreen] respondsToSelector:@selector(brightness)])
            {
                sIsiOS5 = 1;
            }
        }
        return sIsiOS5;
    }
    

    While setting the image, check as following and then set the image.

    if ( [Utilities isIOS5] ) {
        [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"KnavigationBarImage.png"] forBarMetrics:UIBarMetricsDefault];
    }
    else
    {
        self.navigationController.navigationBar.layer.contents = (id)[UIImage imageNamed:@"KnavigationBarImage.png"].CGImage;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to set the background image of canvas using canvas.setBackgroundImage(image); How can i
I am trying to set an image as the background of a custom UIButton.
I'm trying to set a background image of an NSView. (Actually an NSScrollView.) At
I'm trying to programmatically set the background image for a tabbar in my app.
I am trying to set a different background image for collapsed and expanded headers
This is driving me nuts. I am trying to set a background image to
I am trying to set background image of a div through prototype javascript.The image_path
I'm trying to set the background image for a UITableViewController. I've got the following
I have a problem with Javascript. I'm trying to set a background image for
I'm trying to set the background of an element to no-repeat - I've tried

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.