问题
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.
回答1:
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.
回答2:
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];
回答3:
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
来源:https://stackoverflow.com/questions/19136899/navigation-bar-has-wrong-position-when-modal-a-view-controller-with-flip-horizon