Is possible to add an UIImageView to an UINavigationBar title? - iphone

I have an UINavigationBar, and I'm trying to add the user avatar to before the text, and I want 't so it's just before, and thought if I add it with IB, if the tabBar title is longer it would look ugly, so how could I add it on the front of the navBar? It would look like this of Osfoora:

You could add UIImageView in the titleView property of UINavigationBar.
myImageView is type of UIImageView.
self.navigationItem.titleView = myImageView;

add it as a barbutton image if you are not using any barbutton.

Related

Remove shadow from UIBarButtonItem Image

Is there an easy way to remove the stupid image shadow from a uibarbuttonitem ?
Looks like the only way is to put an UIButton within an UIBarButton. So there is no way to directly remove the shadow from an uibarbutton image.

Adding a background image to a UILabel

I'm attempting to add a UIImageView to the subview of a UILabel, but for some reason, I'm unable to have it as the background as this will cover the actual label text.
I don't want to set the UILabel's background color as because it will repeat as a pattern:
[self setBackgroundColor: [UIColor colorWithPatternImage:[UIImage imageNamed:#"someBg.png"]]];
Looking at the number of subviews to a raw UILabel it seems like the text isn't a UIView so adding the subview to index 0 won't help either.
I need the text to be ON TOP of the image background.
Any ideas?
Your options:
Wrap the label and the background image view in another container view.
Write your own label class that supports background images.
Anyhow I solved this by inheriting UITextField and adding the subview to that. This works since there's actually a UILabel subview within this control and adding it behind it naturally solves the problem.
Also, I disabled user interaction so that it behaves like a label.

How to add image in place of text in navigation bar?

How to add image in place of text in navigation bar ?
Can you use the titleView property of the UINavigationItem ?
UINavigationBar is a subclass of UIView. Thus, you can create your UIImageView object and add it as a subview in your UINavigation bar.
[navigationBar addSubview:imageView];
One thing you need to keep in mind that the navigationbar dimensions which is 320X44 in Portrait & 480X20 points in landscape for iPhone.
u can create an image view with some image and add it to the title view of navigation bar
like:--
self.navigationItem.titleView = myImageView;

Is it possible to set image or button at the center of navigationbar in iphone?

Is it possible to set image or button at the center of navigationbar in iphone?
Yes, have a look at the UINavigationItem's titleView property. In my application I added a UIView with a UILabel and UIImageView, for instance.

transparent subview over UIimageView

as i am a new in iphone world ,i need some startup help to achieve this kind of design? background of view which has button should be transparent so that user can see product image in back.
http://www.freeimagehosting.net/uploads/cb58b72480.jpg
let me know if it requires more explanation?
thanks.
You will have to have a single UIView containing your UIImageView and UIButton.
Using InterfaceBuilder first drag the UIImageView and then drag the UIButton inside the parent UIVIew.
Or programmatically you can call the parent UIView's addSubView method first for the UIImageView and then for the UIButton view
[view addSubview:myImageView]
[view addSubview:myButton]
Either of this approach will place the instance UIButton on top of the UIImageView when the UIView is rendered
Also, FYI, transparency of a View can be controlled through its alpha property
alpha = 0 being the most transparent and
alpha = 1 being the most opaque
Hope this helps.