动画显示和隐藏Tabbar和NaviBar

Jan 19, 2017

‘//隐藏标签栏

  • (void)hiddenTheTabBar
    {
    if (![[NSUserDefaults standardUserDefaults] boolForKey:@”isHiddenTabBar”]) {
    for (UIView *v in [self.view subviews]) {
    if ([v isKindOfClass:[UITabBar class]]) {
    [UIView animateWithDuration:0.5f delay:0.0f options:UIViewAnimationOptionCurveEaseOut animations:^(){
    CGRect frame = v.frame;
    frame.origin.y += 49.0f;
    v.frame = frame;
    } completion:nil];
    } else {
    [UIView animateWithDuration:0.5f delay:0.0f options:UIViewAnimationOptionCurveEaseOut animations:^(){
    CGRect frame = v.frame;
    frame.size.height += 49.0f;
    v.frame = frame;
    } completion:nil];
    }
    }
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@”isHiddenTabBar”];
    }
    }
    //显示标签栏
  • (void)showTheTabBar
    {
    if ([[NSUserDefaults standardUserDefaults] boolForKey:@”isHiddenTabBar”]) {
    for (UIView *v in [self.view subviews]) {
    if ([v isKindOfClass:[UITabBar class]]) {
    [UIView animateWithDuration:0.3f delay:0.0f options:UIViewAnimationOptionCurveEaseOut animations:^(){
    CGRect frame = v.frame;
    frame.origin.y -= 49.0f;
    v.frame = frame;
    } completion:nil];
    } else {
    [UIView animateWithDuration:0.3f delay:0.0f options:UIViewAnimationOptionCurveEaseOut animations:^(){
    CGRect frame = v.frame;
    frame.size.height -= 49.0f;
    v.frame = frame;
    } completion:nil];
    }
    }
    [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@”isHiddenTabBar”];
    }
    }

    思路就是这样,别人那边看到的,就是找出来,然后拿着这玩意做动效,存着吧