Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
555 views
in Technique[技术] by (71.8m points)

cocoa touch - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...