Phillip
Phillip

Reputation: 4306

iOS 7 - Navigation Controller Toolbar issue with setToolbarHidden: animation

In my Tabbed application, the main view is an UITableView, which includes a hidden searchBar (until you scroll down and it shows up, just like the Mail app).

In the navigation bar, there's a button which brings up the navigationController's toolbar with an animation.

The toolbar is positioned just above the tabBar.

The problems are:

The code I'm using is

-(void)showToolbar{
    [UIView animateWithDuration:0.3 animations:^{
        [self.navigationController setToolbarHidden:NO animated:YES];
        [self.navigationController.toolbar setAlpha:1.0];
    }completion:nil];
}


-(void)hideToolbar{
    [UIView animateWithDuration:3.0
                     animations:^{
                         [self.navigationController setToolbarHidden:YES animated:YES];
                         [self.navigationController.toolbar setAlpha:0.0];
                     }
                     completion:nil];
}

Here's a gif of what i'm getting (blurred for privacy reasons)

Any suggestion appreciated.

Upvotes: 2

Views: 717

Answers (1)

BHASKAR
BHASKAR

Reputation: 1201

I think the cause of the black-ish background before the toolbar actually shows up is it shows your application window background color. if you do this

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    [self.window setBackgroundColor:[UIColor yellowColor]];
    return YES;
}

Then it shows yellowish background before toolbar is coming.It will show whatever color you set in your app mainwindow it display. It shows because in your showtoolbar is running for 0.3 sec in this time your toolbar alpha change from 0.0 to 1.0 so for some miliseconds it will be blank.

So the solution is you can change the duration time to 0.1 or you can set the same backgroundcolor to your uiwindow.. :)

Upvotes: 1

Related Questions