Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to display an image in the navigation bar of an iPhone application?

Tags:

how to display an image in the navigation bar of an iPhone application? (say, right after the title)

like image 996
ebaccount Avatar asked May 10 '09 00:05

ebaccount


People also ask

How do I add a picture to navigation bar?

We just need to add a div tag with the class as a container and put the navbar-brand(image or logo) inside this div. After that, we just need to add the class mx-auto to the navbar-brand class.

How do I change the navigation bar on my Iphone?

A user changes the navigation bar's style, or UIBarStyle , by tapping the “Style” button to the left of the main page. This button opens an action sheet where users can change the background's appearance to default, black-opaque, or black- translucent.

How do I customize my navigation bar?

From Settings, tap Display, and then tap Navigation bar. Make sure Buttons is selected, and then you can choose your desired button setup at the bottom of the screen. Note: This option will also affect the location you swipe when using Swipe gestures.

Does Apple have a navigation bar?

macOS doesn't provide a navigation bar. To enable navigation in a macOS app, you often use a sidebar or a navigation control like a Back button in a toolbar. Also, you typically display the title of a macOS window in the title bar.


2 Answers

Here's how to have the image centered in the NavBar.

UIImage *image = [UIImage imageNamed: @"NavBarImage.png"]; UIImageView *imageView = [[UIImageView alloc] initWithImage: image];  self.navigationItem.titleView = imageView;  [imageView release]; 

This code is actually contained with the Apple source for the NavBar and can be found at the iPhone Developer Center at Apple. The source shows you various ways to manipulate both the StatusBar & NavBar.

like image 104
Magnatek Avatar answered Oct 20 '22 04:10

Magnatek


I haven't tested this but as UINavigationBar is a view you can add subViews to it.

UIImage* myImage = [UIImage imageNamed:@"Myimage.png"]; UIImageView* myImageView = [[UIImageView alloc] initWithImage:myImage]; myImageView.frame.origin.x = 30.0; // You will have to find suitable values for the origin myImageView.frame.origin.y = 5.0;  [myTabbar addSubView:myImageView]; [myImageView release]; 

You can use things like the backItem property to calculate the position of your image view.

like image 44
Rog Avatar answered Oct 20 '22 05:10

Rog