1

Does anyone have any elegant solution to move UIView in front of a UINavigationBar?

I want the following to happen:

1 - click the green button

2 - green button and blue view slide up to UINavigationBar

3 - green button stay on top of UINavigationBar

enter image description here

Andre Cytryn
  • 2,506
  • 4
  • 28
  • 43
  • Have you tried the `bringSubviewToFront` method? - http://stackoverflow.com/questions/13182482/bringing-a-subview-to-be-in-front-of-all-other-views – MendyK Mar 11 '15 at 02:01

1 Answers1

1

Not the most elegant solution, but I think you will need to remove the button from it's current view hierarchy and add it to the navigation controller view.

e.g.

- (void)buttonPress:(UIButton *)sender {

    [UIView animateWithDuration:0.3 animations:^{
        [sender removeFromSuperview];
        [self.navigationController.view addSubview:sender];
        [sender setFrame:CGRectMake(sender.frame.origin.x, self.navigationController.navigationBar.frame.origin.y, sender.frame.size.width, sender.frame.size.height)];
    }];

}
Weaverfish
  • 930
  • 8
  • 17