如何使UINavigationBar中的UISearchBar仅使用块animation调整左边距?

我正在尝试复制在移动Safari中看到的UISearchBaranimation。 而不是只移动左边距,UISearchBar从屏幕上展开,然后“跳转”到适当的位置。 裁员同样不均衡。 我怎样才能使这个animation甚至像移动Safari浏览器中的UISearchBar?

searchBar = [[[UISearchBar alloc] initWithFrame:CGRectMake(0,0,175,44)] autorelease]; searchBar.delegate = self; searchBar.showsCancelButton = YES; searchBar.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth; UIBarButtonItem *customBarItemRight = [[[UIBarButtonItem alloc] initWithCustomView:searchBar] autorelease]; tabBarController.navigationItem.rightBarButtonItem = customBarItemRight; - (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar { searchDisplayController.searchResultsTableView.hidden = NO; [UIView animateWithDuration:.3 animations:^ { CGRect newBounds = searchBar.bounds; newBounds.size.width = 350; searchBar.bounds = newBounds; }]; [searchDisplayController setActive:YES animated:YES]; } 

你不应该为此使用UISearchDisplayController,你需要为你的自定义视图控制器实现animation。