0

I am making an app in which I created custom navigation bar - MyNavigationBar (extends UIView):

MyNavigationBar.xib :

nib of that custom view

MyNavigationBar.m :

    +(id)navigationBar{
    MyNavigationBar * bar = (MyNavigationBar *) [[[NSBundle mainBundle] loadNibNamed:@"MyNavigationBar" owner:self options:nil] objectAtIndex:0];
    return bar;
}

Then in NavigationViewController implementation I use this code to add view showed above to navigationBar:

NavigationViewController.m:

    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        _navBar = [MyNavigationBar navigationBar];
        [self.navigationBar addSubview:_navBar];
    }
    return self;
}

When the left button (subview of MyNavigationBar) is pressed

[[self navigationController] popViewControllerAnimated:YES];

is called.

And the problem is that on that pop animation glitch happens, it looks like this:

enter image description hereenter image description here

Back button become visible for all animation duration and then disappears.

I have tried this but nothing happens:

[_navigationBar.backItem setHidesBackButton:YES];
haawa
  • 3,078
  • 1
  • 26
  • 35

1 Answers1

0

Instead of adding custom subview to navigation bar try setting navigationItem.titleView to your custom UIView or use [UINavigationBar appearance] and [UIBarButtonItem appearance] APIs to customize standard controls.

Jeepston
  • 1,361
  • 7
  • 7