I figured it out. I added another button to the animation and then tried changing the toolbar frame in the completion block instead and it worked! The other button is just there to resignFirstResponder by pressing outside the keyboard. I have no idea why it worked this way but I am not complaining:
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
self.done = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 0)];
self.done.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
[self.done addTarget:self action:@selector(doneButton:) forControlEvents:UIControlEventTouchUpInside];
[self.navigationController.view addSubview:self.done];
[UIView animateWithDuration:0.25
delay:0.0
options:UIViewAnimationOptionCurveEaseIn
animations:^{
[self.done setFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height - 172 + 20)];
}
completion:^(BOOL finished) {
[self.navigationController.toolbar setFrame:CGRectMake(0, self.view.bounds.size.height - 172 + 20, 320, 44)];
}
];
}
Another thing I noticed is that I couldn't change the translucent property of my tool bar. When I tried to implement:
self.navigationController.toolbar.translucent = YES;
or when I tried to implement:
self.navigationController.toolbar.barStyle = UIBarStyleBlackTranslucent;
It caused the animation completion block code to not work. I'm not sure if this is a bug or what?