Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Background Image for UINavigationcontroller

I want to add background image to uinavigationcontroller. Please help me.

like image 390
Hasintha Janka Avatar asked Mar 28 '12 10:03

Hasintha Janka


People also ask

How do you put a background picture on storyboard?

Go to 'View->Show Library' and choose the Image View and drag it to the middle of the screen until it snaps perfectly in the center. This Image View will serve as the background image and it will fill the entire screen, including the area past the safe area view.

How can I cover an image in tag?

Just set object-fit: cover; on the img .

How do you fit a background image vertically in CSS?

If I do background-size: 100%, it sets both width and height to a 100%. This was pretty handy. In my case, I set "background-size: 960px 100%;" to get the desired effect.


3 Answers

Use this

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [self.window makeKeyAndVisible];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"yourImage"] forBarMetrics:UIBarMetricsDefault];
    return YES;
}
like image 27
Ujwal Avatar answered Oct 07 '22 11:10

Ujwal


Try this

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"yourImage"] forBarMetrics:UIBarMetricsDefault];
like image 191
Hemang Avatar answered Oct 07 '22 10:10

Hemang


code on swift 3 and swift 4

UINavigationBar.appearance().setBackgroundImage(UIImage(named:"pattern.png"),
                                                            for: .default)
like image 42
amisha.beladiya Avatar answered Oct 07 '22 10:10

amisha.beladiya