naveen kumar
naveen kumar

Reputation: 101

Extra UINavigationBar showing in iOS?

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]

Xcode enter image description here

[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]];

full screen storyboard

Upvotes: 0

Views: 96

Answers (2)

Dree
Dree

Reputation: 722

Go to your root navigation controller, select the navigation bar and under the Attributes Inspector, make sure you have:

  1. Default style,
  2. Translucent option enabled,
  3. Default bar tint.

Upvotes: 0

Avijit Nagare
Avijit Nagare

Reputation: 8782

I think code is correct just set contentMode property.

[[myButton imageView] setContentMode: UIViewContentModeScaleAspectFit];

Same for other buttons.

Upvotes: 0

Related Questions