I'm trying to add a simple animation when I resize the UISearchBar from the leftBarButtonItem. For some reason, the resize doesn't animate, although the searchBar's size is modified. However, if I try to modify the searchBar's alpha it does animate.
Here is the code
UISearchBar *baseSearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:baseSearchBar];
And the animation method is:
[UIView animateWithDuration:2.0f animations:^{
searchBar.frame = CGRectMake(0, 0, 400, 40);
searchBar.alpha = 0;
} completion:^(BOOL finished) {
}];
As i said, the resize DOES work, but not animated and the animation works if I'm trying to change the alpha.
One more thing... I tried to do the same thing for the rightBarButtonItem and the animation worked..
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(expandWithAnimation:)
forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Test" forState:UIControlStateNormal];
button.frame = CGRectMake(0, 0, 50, 40);
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
Thank you in advance