I created an iPad application in which I would like to have my searchBar to be positioned in the right of a navigation bar.
When I add my search bar in my navigation bar, it is positioned in the middle of the navigationBar. In the middle, instead, I want to show a specific image.
How can I achieve this?
Here is my code snippet,
[self.navigationController.navigationBar setTintColor:[[UIColor alloc]initWithRed:150.0 / 255 green:22.0 / 255 blue:22.0 / 255 alpha:0.0]];
UIImage *image = [UIImage imageNamed:@"logo(1).png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[self.navigationItem setTitleView:imageView];
self.navigationItem.titleView = sBar;
[titleView release];
With the code above, I am able to see only the searchBar (positioned in the middle) in my simulator.
Try this:
You can always change the frame. Always keep in mind that the
backgroundImageproperty is only available in iOS 5. You should search for alternative options to get rid of the background for iOS 4.xLet me know if that works for you.