Reputation: 836
I am newbie for IOS. So I have tried to customize the UINavigationBar with out using navigation controller. I have able to change the tile and background color but I have tried to setting the background image programmatically its not working.whether its possible to set background image using story board itself ? I have tried may websites in that mostly used programmatically. so any possible way to set the background image using UIStoryboard ?
Upvotes: 2
Views: 422
Reputation: 82759
we can do like
and you get the output of
Note
if you load the Image from Assests use like UIImage(named: "xx")
if let img = UIImage(named: "xx")
{
self.topBar.setBackgroundImage( img , forBarMetrics: .Default)
}
else if you load the Image from resource bundle use like UIImage(named: "xx.extenson (.png )")
if let img = UIImage(named: "xx.jpg")
{
self.topBar.setBackgroundImage( img , forBarMetrics: .Default)
}
you can check with this function in apple douments
here I attached the sample Project link Download and check once
Upvotes: 2
Reputation: 2693
You can use
[yourNavigationbar setBackgroundImage:[UIImage imageNamed: @"YourBackgroundImage.png"]
forBarMetrics:UIBarMetricsDefault];
For Swift
yourNavigationbar.setBackgroundImage(UIImage(named: "YourBackgroundImage.png"),
forBarMetrics: .Default)
Upvotes: 0