IOS Animation issue in UISearchBar

I am doing a lot of customization for a pair of search bars that are next to each other in the same view. Below is an animation block in which the search bar on the left is aligned to the width of the screen when selected. The end result is exactly what I want, but for some reason there is no animation when the UIView calls animateWithDuration.

- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar {
UISearchBar *tempSearchBar = (UISearchBar *) searchBar;

if (tempSearchBar.tag == 1) {
    self.customSearchBar.frame = CGRectMake(0, 0, 185, 44);
    [UIView animateWithDuration:.3
                          delay:0
                        options:UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         self.customSearchBar.frame = CGRectMake(0, 0, 320, 44);
                         self.customLocationBar.frame = CGRectMake(320, 0, 0, 44);
                         self.customLocationBar.hidden = YES;
                     } completion:^(BOOL finished) {
                         self.customSearchBar.showsCancelButton = YES;
                     }];
    self.customSearchBar.autocorrectionType = UITextAutocorrectionTypeNo;
}
}

      

Any help would be greatly appreciated.

Thank!

+3


source to share





All Articles