Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation bar has wrong position when modal a view controller with flip horizontal transition in iOS 7

When I am trying to modal a view controller with flip horizontal transition in iOS7, the origin of navigation bar is (0, 0) at beginning and then jump to the right position at (0, 20). Is it possible to make it behave the same with in iOS6? You can download the project here.

I have created a customized navigation bar as following:

@implementation MyCustomNavigationBar

- (void)drawRect:(CGRect)rect {
    [super drawRect:rect];
    UIImage *image = [UIImage imageNamed:@"Custom-Nav-Bar-BG.png"];


    [image drawInRect:CGRectMake(0,  0, self.frame.size.width, self.frame.size.height)];

    if (IOSVersion <7) {
    }else{
        self.translucent = NO;
        self.tintColor = [UIColor whiteColor];
        self.barStyle = UIBarStyleDefault;
        self.barTintColor = [UIColor redColor];

    }
}

@end

Any help will be appreciated.

like image 347
lu yuan Avatar asked Oct 02 '13 12:10

lu yuan


3 Answers

I have the same problem with you. I think It's a bug with UIKit on iOS 7.

I added a little of code at viewWillAppear method on presentation

     [self.navigationController.navigationBar.layer removeAllAnimations];

When I dismiss this view, I added:

-(IBAction)btnDonePressed:(id)sender {
    [UIView transitionWithView:self.navigationController.view
                      duration:0.75
                       options:UIViewAnimationOptionTransitionFlipFromLeft
                    animations:nil
                    completion:nil];
    [self dismissViewControllerAnimated:YES completion:nil];
}

This worked for me. Hope this helps you.

like image 84
Thanh Vũ Trần Avatar answered Oct 20 '22 02:10

Thanh Vũ Trần


Instead of hacking [navigationBar.layer removeAllAnimations];, something like this should work as well:

[UIView transitionWithView:self.view.window duration:FlipDuration options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{
    [UIView performWithoutAnimation:^{
        [self presentViewController:modalController animated:NO completion:nil];
    }];
} completion:nil];
like image 33
Vadim Avatar answered Oct 20 '22 04:10

Vadim


Just give the -20 in the xib in option "ios 6/7 Deltas"

or read this

https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/index.html#//apple_ref/doc/uid/TP40006556-CH66-SW1

like image 3
virantporwal Avatar answered Oct 20 '22 02:10

virantporwal