I want to have the logo of my app followed by the app name on the navigation bar. Along with this, there should be a back button.
Below is a screenshot :
I've tried the code below.
self.navigationItem.setHidesBackButton(false, animated:true);
let imgLogo : UIImage = UIImage(named:"Logo")!
let imgViewLogo : UIImageView = UIImageView(image: imgLogo)
imgViewLogo.frame = CGRectMake(0, 0, 40, 40)
let leftItem:UIBarButtonItem = UIBarButtonItem(customView: imgViewLogo)
self.navigationItem.leftBarButtonItem = leftItem
// App Name set on storyboard at design-time
This places the logo on top of the back button shown below.
How can this be achieved?
You can use custom view for navigationItem.titleView
. Create UIView with your logo and a label for UIViewController title and set
navigationItem.titleView = YOUR_CUSTOM_VIEW;