0

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

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
naveen kumar
  • 101
  • 1
  • 8

2 Answers2

0

I think code is correct just set contentMode property.

[[myButton imageView] setContentMode: UIViewContentModeScaleAspectFit];

Same for other buttons.

Avijit Nagare
  • 8,482
  • 7
  • 39
  • 68
0

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.
Dree
  • 702
  • 9
  • 29