iOS无法将动画应用于UISearchBar

时间:2012-03-21 18:01:51

标签: ios animation uisearchbar

我正在对同一视图中并排的几个搜索栏进行大量自定义。下面是一个动画块,左侧的搜索栏在选择时占据屏幕的宽度。最终结果正是我想要的,但由于某种原因,在调用UIView 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;
}
}

非常感谢任何帮助。

谢谢!

0 个答案:

没有答案