我想隐藏按下按钮时不在UINavigationBar
内的UINavigationController
(这是模态视图)。
我该怎么做?我希望它能够动画。
答案 0 :(得分:2)
如果你想要它的动画,你可以将其alpha设置为0.0
[UIView beginAnimations:@"Hide bar animation" context:NULL];
[UIView setAnimationDuration:0.5];
navigationBar.alpha = 0.0;
[UIView commitAnimations];
然后回到1.0以取消隐藏
[UIView beginAnimations:@"Show bar animation" context:NULL];
[UIView setAnimationDuration:0.5];
navigationBar.alpha = 1.0;
[UIView commitAnimations];
虽然在iOS 4+中,鼓励使用块动画方法
+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion
你可以这样使用:
[UIView animateWithDuration:0.5
animations:^{
navigationBar.alpha = 0.0;
}
completion:^(BOOL finished){
/* some completion code */
}];