0
A
回答
0
UITapGestureRecognizer* tapGesture =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(your_selector)];
tapGesture.numberOfTapsRequired = 2;
[self.view addGestureRecognizer:tapGesture];
[tapGesture release];
在您選擇:
-(void)your_selector{
[UIView animateWithDuration:0.5
animations:^{
bar.frame = CGRectOffset(bar.frame, 0, bar.bounds.size.height*bar.frame.origin.y<0?-1:1);
}];
}
在此實現你只有雙觸摸會改變條狀態的事件。 不幸的是,一次沒有簡單的單觸和雙觸手勢的實現。更多的人類行爲,對你而言更容易 - 只有在雙重接觸的情況下才能工作。
0
試試這個隱藏
[UIView beginAnimations:@"Hide bar animation" context:NULL];
[UIView setAnimationDuration:0.5];
navigationBar.alpha = 0.0;
[UIView commitAnimations];
for showing
[UIView beginAnimations:@"Show bar animation" context:NULL];
[UIView setAnimationDuration:0.5];
navigationBar.alpha = 1.0;
[UIView commitAnimations];
但UINavigationController的太簡單......
+0
你是什麼意思的隱藏欄動畫和顯示欄導航?可以在viewwillappear中查看這些代碼嗎?viewwilldis會出現嗎? – Priya 2012-01-18 11:28:11
+0
都只是應用程序提供的動畫標識符。你可以設置任何字符串爲 – 2012-01-18 11:32:45
0
你可以有一個UINavigationBar
沒有導航控制器:
navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 40.0f)];
[navBar setDelegate:self];
[mainView addSubview:navBar];
UITapGestureRecognizer
是UIGestureRecognizer
具體子類,尋找單個或多個龍頭:
UITapGestureRecognizer *doubleTap =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideNavBar:)];
[doubleTap setNumberOfTapsRequired:2];
[YOURVIEW addGestureRecognizer:doubleTap];
UITapGestureRecognizer *singleTap =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showNavBar:)];
[singleTap setNumberOfTapsRequired:1];
[YOURVIEW addGestureRecognizer:singleTap];
這裏有顯示或隱藏導航欄的方法:
- (void)hideNavBar:(id)sender
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0f]; //Animation duration in seconds
navBar.alpha = 0.0f;
[UIView commitAnimations];
}
- (void)showNavBar:(id)sender
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0f]; //Animation duration in seconds
navBar.alpha = 1.0f;
[UIView commitAnimations];
}
相關問題
- 1. 點擊時隱藏導航欄
- 2. 隱藏導航欄
- 3. 隱藏導航欄?
- 4. 隱藏導航欄
- 5. 隱藏導航欄
- 6. 隱藏導航條,顯示導航欄
- 7. UISearchDisplayController隱藏導航欄
- 8. 保持導航欄隱藏
- 9. SWIFT:導航欄不隱藏
- 10. Nativescript - 隱藏導航欄(IOS)
- 11. 隱藏導航欄像facebook
- 12. 如何隱藏導航欄?
- 13. React Native - 隱藏導航欄
- 14. FBUserSettingsViewController隱藏導航欄
- 15. 隱藏導航欄永久
- 16. GMSMapView中隱藏導航欄
- 17. 導航欄隱藏錨點
- 18. 如何隱藏導航欄?
- 19. 隱藏導航欄旋轉
- 20. 標籤導航欄隱藏
- 21. 隱藏導航欄標題
- 22. IPHONE:ABPeoplePickerNavigationController隱藏導航欄
- 23. 問題隱藏導航欄
- 24. SFSafariViewController:隱藏導航欄
- 25. 隱藏導航欄時查看跳轉
- 26. 觸摸導航欄時隱藏鍵盤
- 27. 滾動時隱藏bootstrap導航欄
- 28. 無法隱藏導航欄時刷
- 29. 視圖中隱藏導航欄時,
- 30. 滾動時隱藏導航欄
,但它不工作... – Priya 2012-01-18 12:21:03
什麼不工作?選擇器不調用或酒吧不移動? – OdNairy 2012-01-18 12:28:28
它沒有隱藏起來。 – Priya 2012-01-18 12:29:34