Reputation: 723
I am developing an application in iphone. I have to add an image on to my view or on UINavigation bar. My condition is that the image will be added partially on navigation bar and partially on view.
I have added it as a barbutton item into titleview but its height is limited by bar height. I need it to drop below navigation bar.
How it can be implemented?
Thanks in advance.
Upvotes: 2
Views: 1953
Reputation: 109
#define kWidth [UIScreen mainScreen].bounds.size.width
In the <UIViewController.m>:
- (void)viewDidLoad
{
UIImageView *titleImageView = [[UIImageView alloc] initWithFrame:CGRectMake(kWidth-10, 0, 20, 20)];
titleImageView.image = [UIImage imageNamed:@"The Image Name"];
titleImageView.contentMode = UIViewContentModeScaleAspectFit;
self.navigationItem.titleView = titleImageView;
}
It works for me , does it work for you ? Good luck!
Upvotes: 0
Reputation: 222
You could add the image view as a subview of the navigation bar, something like this:
[myNavBar insertSubview:myImageView atIndex:0];
Upvotes: 1
Reputation: 12036
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yourImageName"]];
imageView.frame = CGRectMake(100, 0, 200, 80);
[self.parentViewController.view.window addSubview:imageView];
[imageView release];
Upvotes: 0