Reputation: 101
I have an issue With UINavigationBar , when i add UIButton over there and when i run the application i can see one extra UINaviagtionBar overlay on top of my UINavigationBar.
Please help
The structure is like
UITabbarController -> UINavigationController -->UIViewController
I have attached screen shots link
Run time[![[1]][1]][1]
[navigationcontroller->viewcontroller screen][3]
Code
ViewDidAppear()
UIImage *myImage = [UIImage imageNamed:@"filter.png"];
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom];
[myButton setImage:myImage forState:UIControlStateNormal];
myButton.showsTouchWhenHighlighted = YES;
myButton.frame = CGRectMake(0.0, 0.0,25,25);
[myButton addTarget:self action:@selector(refreshSection) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithCustomView:myButton];
self.navigationItem.leftBarButtonItem = rightButton;
UIImage *myImage1 = [UIImage imageNamed:@"Contacts.png"];
UIButton *myButton1 = [UIButton buttonWithType:UIButtonTypeCustom];
[myButton1 setImage:myImage1 forState:UIControlStateNormal];
myButton1.showsTouchWhenHighlighted = YES;
myButton1.frame = CGRectMake(0.0, 0.0,30,30);
[myButton1 addTarget:self action:@selector(profile) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rightButton1 = [[UIBarButtonItem alloc] initWithCustomView:myButton1];
[self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:rightButton1, nil]];
Upvotes: 0
Views: 96
Reputation: 722
Go to your root navigation controller, select the navigation bar and under the Attributes Inspector, make sure you have:
Upvotes: 0
Reputation: 8782
I think code is correct just set contentMode property.
[[myButton imageView] setContentMode: UIViewContentModeScaleAspectFit];
Same for other buttons.
Upvotes: 0