美文网首页
Objective-C页面消失或出现时,判断是pop还是push

Objective-C页面消失或出现时,判断是pop还是push

作者: tinghua | 来源:发表于2016-11-25 16:24 被阅读319次
    • (void)viewWillDisappear:(BOOL)animated {
      NSArray *viewControllers = self.navigationController.viewControllers;//获取当前的视图控制其
      if (viewControllers.count > 1 && [viewControllers objectAtIndex:viewControllers.count-2] == self) {
      //当前视图控制器在栈中,故为push操作
      NSLog(@"push");
      } else if ([viewControllers indexOfObject:self] == NSNotFound) {
      //当前视图控制器不在栈中,故为pop操作
      NSLog(@"pop");
      }
      }

    [self.navigationController setNavigationBarHidden:YES animated:animated];
    设置是否隐藏导航栏,隐藏view界面上移

    [self.navigationController.navigationBar setBarTintColor:KMainColor];设置导航栏的颜色

    [self.navigationController.navigationBar setBarStyle:UIBarStyleBlackTranslucent];
    设置导航栏的风格
    UIBarStyleDefault:文字颜色为黑色
    UIBarStyleBlack = 1,
    UIBarStyleBlackOpaque = 1,
    UIBarStyleBlackTranslucent = 2
    文字颜色为白色

    self.navigationController.navigationBar.translucent = YES;表示view从0,0开始
    self.navigationController.navigationBar.translucent = NO;表示view从navigationBar下方开始

    相关文章

      网友评论

          本文标题:Objective-C页面消失或出现时,判断是pop还是push

          本文链接:https://www.haomeiwen.com/subject/zxcwpttx.html