iOS如何導(dǎo)航欄無縫圓滑的隱藏Navigationbar

這篇文章將為大家詳細(xì)講解有關(guān)iOS如何導(dǎo)航欄無縫圓滑的隱藏Navigationbar,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

十多年的陜州網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。營銷型網(wǎng)站的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整陜州建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)從事“陜州網(wǎng)站設(shè)計(jì)”,“陜州網(wǎng)站推廣”以來,每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

1.ViewController

.m

- (void)viewDidLoad {
 [super viewDidLoad];
 self.title = @"隱藏導(dǎo)航欄";
 UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
 button.backgroundColor = [UIColor lightGrayColor];
 button.frame = CGRectMake(10, 100, 60, 30);
 [button addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];
 [self.view addSubview:button];
 self.navigationController.delegate = self;
}
- (void)buttonClick{
 ///跳轉(zhuǎn)到KKViewController
 [self performSegueWithIdentifier:@"pusht" sender:nil];
}

頭部代理

@interface ViewController ()<UINavigationControllerDelegate>

代理方法

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
 [self.navigationController setNavigationBarHidden: [self hiddenBarVc: viewController] animated: animated];
}
- (BOOL)hiddenBarVc:(UIViewController *)viewController {
 BOOL needHideNaivgaionBar = NO;
 if ([viewController isKindOfClass: [KKViewController class]]) {
 needHideNaivgaionBar = YES;
 }
 return needHideNaivgaionBar;
}

2.KKViewController(目標(biāo)ViewController)

新建一個(gè)KKViewController

.h

@property (nonatomic,strong) id popDelegate;

.m

- (void)viewDidLoad {
 [super viewDidLoad];
 self.title = @"第二個(gè)頁面";
 [self popSet];
}
- (void)popSet{
 _popDelegate = self.navigationController.interactivePopGestureRecognizer.delegate;
 SEL action = NSSelectorFromString(@"handleNavigationTransition:");
 UIPanGestureRecognizer *popPanGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self.popDelegate action:action];
 popPanGesture.maximumNumberOfTouches = 1;
 popPanGesture.delegate = self;
 [self.view addGestureRecognizer: popPanGesture];
}

頭部代理

@interface KKViewController ()<UIGestureRecognizerDelegate>

手勢(shì)代理方法

- (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer{
 ///【下面兩個(gè)方法寫一個(gè)】
 ///全屏拖動(dòng)
 CGPoint tragPoint = [gestureRecognizer translationInView:gestureRecognizer.view];
 if (tragPoint.x <= 0){
  return NO;
 }
 else{
  if (self.navigationController.viewControllers.count <= 1){
   return NO;
  }
  else{
   return YES;
  }
 }
// ///局部允許拖動(dòng)
// CGPoint tragPoint = [gestureRecognizer locationInView:gestureRecognizer.view];
// NSLog(@"x=%f;y=%f",tragPoint.x,tragPoint.y);
// if (tragPoint.x > 60){///拖動(dòng)的范圍
//  return NO;
// }
// else{
//  if (self.navigationController.viewControllers.count <= 1) {
//   return NO;
//  }
//  else{
//   return YES;
//  }
// }
}

效果圖

iOS如何導(dǎo)航欄無縫圓滑的隱藏Navigationbar

關(guān)于“iOS如何導(dǎo)航欄無縫圓滑的隱藏Navigationbar”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。

網(wǎng)站題目:iOS如何導(dǎo)航欄無縫圓滑的隱藏Navigationbar
網(wǎng)址分享:http://muchs.cn/article6/jepjig.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、網(wǎng)站設(shè)計(jì)自適應(yīng)網(wǎng)站、用戶體驗(yàn)App設(shè)計(jì)、虛擬主機(jī)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)