[英]Odd animation in UINavigationBar (UIBarButtonItem with custom view)
[英]Custom animation when hiding UINavigationBar
我正在制作一個應用程序,在單擊時顯示/隱藏(在自定義動畫中)UINavigationBar。
我創建了兩個函數(一個用於顯示,另一個用於隱藏)。 顯示UINavigationBar的功能完美無缺:
- (void) showNavigationBar {
[UINavigationBar beginAnimations:@"NavBarFadeIn" context:nil];
self.navigationController.navigationBar.alpha = 0;
[UINavigationBar setAnimationCurve:UIViewAnimationCurveEaseIn];
[UINavigationBar setAnimationDuration:0.5];
[UINavigationBar setAnimationTransition:UIViewAnimationOptionTransitionFlipFromTop
forView:self.navigationController.navigationBar
cache:YES];
self.navigationController.navigationBar.alpha = 1;
[UINavigationBar commitAnimations];
}
但隱藏它的功能,即使它是相同的,也不起作用。 沒有動畫,UINavigationBar突然消失。
- (void) hideNavigationBar {
[UINavigationBar beginAnimations:@"NavBarFadeOut" context:nil];
self.navigationController.navigationBar.alpha = 1;
[UINavigationBar setAnimationCurve:UIViewAnimationCurveEaseIn];
[UINavigationBar setAnimationDuration:0.5];
[UINavigationBar setAnimationTransition:UIViewAnimationOptionTransitionCurlUp
forView:self.navigationController.navigationBar
cache:YES];
self.navigationController.navigationBar.alpha = 0;
[self.navigationController setNavigationBarHidden:YES animated:NO];
[UINavigationBar commitAnimations];
}
呼喚:
- (void)contentView:(ReaderContentView *)contentView touchesBegan:(NSSet *)touches
{
if( [[self navigationController] isNavigationBarHidden] == NO)
{
if (touches.count == 1) // Single touches only
{
UITouch *touch = [touches anyObject]; // Touch info
CGPoint point = [touch locationInView:self.view]; // Touch location
CGRect areaRect = CGRectInset(self.view.bounds, TAP_AREA_SIZE, TAP_AREA_SIZE);
if (CGRectContainsPoint(areaRect, point) == false) return;
}
[mainToolbar hideToolbar];
[mainPagebar hidePagebar]; // Hide
[self hideNavigationBar];
lastHideTime = [NSDate new];
}
}
有人知道為什么會這樣嗎?
它正在發生,因為你正在調用[self.navigationController setNavigationBarHidden:YES animated:NO];
在動畫代碼中,但boolian值不可動畫。 bool值沒有“值之間”。
你應該調用[self.navigationController setNavigationBarHidden:YES animated:NO];
在您使用動畫后安排的方法中
[UINavigationBar setAnimationDidStopSelector: @selector(myCoolMethod:)];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.