I have a detailview with a navigation bar with a back button and a name for the view. The navigation bar is set programmatically. The name presented is set like this.
self.title = NSLocalizedString(name, @"");
The name depends on the presented view.
Now I would like to also present a small icon on the navigation bar which also is depends on the view.
How do I do that?
You can set backGround image to navigationBar Using this
Put in
didFinishLaunchingWithOptions
Or you can set navigation bar image in any view using
Or you can set a view on your NavigationBar Link
or
And set title using h
And you can get navigationBarButton using this
And set simple imageView on navigation Bar
You need to subclass UINavigationBar. Then in drawRect do something like:
and call the super method ofcourse
Add this code into
viewDidLoad
in your ViewController:imageView can also be declared as an instance variable, so you can access it after you've added it (e.g. if you want to remove your icon from your navigationBar at some point).