导航栏渐变隐现

页面不显示导航栏,上托一定的距离显示导航栏.

设置导航栏存在且透明:

1.设置导航栏的透明:

   //导航栏透明

    self.navigationController.navigationBar.translucent = YES;

    //导航栏背景图

    UIImage *image = [[UIImage alloc] init];

    [self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];

    //导航栏下面的线

    [self.navigationController.navigationBar setShadowImage:image];

    //导航栏透明

    self.navigationController.navigationBar.alpha = 0;

2.设置导航栏显示

  self.navigationController.navigationBar.translucent = NO;

  [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];

  [self.navigationController.navigationBar setShadowImage:nil];

  self.navigationController.navigationBar.alpha = 1;

3.渐变加入动画就好:

        [UIView animateWithDuration:1 animations:^{ };

4.自己实现导航栏的模态推出(搜的)

  [UIView animateWithDuration:1.5 animations:^{

        CATransition* transition = [CATransition animation];

        transition.type=kCATransitionPush;//可更改为其他方式

        transition.subtype = kCATransitionFromTop;//可更改为其他方式

        [self.navigationController.view.layer addAnimation:transition forKey:kCATransition];

        [self.navigationController pushViewController:login animated:NO];

    }];

你可能感兴趣的:(导航栏渐变隐现)