本文介绍了如何让我的UISearchBar在UINavigationBar的使用块动画只调整左边距?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图复制在移动Safari浏览器看到的UISearchBar动画。代替只移动左缘,的UISearchBar扩展超出屏幕,然后跳跃到适当的位置。裁员也同样参差不齐。我怎样才能让这个动画偶喜欢的UISearchBar在移动版Safari?
搜索栏= [[[的UISearchBar页头] initWithFrame:方法CGRectMake(0,0,175,44)自动释放];
searchBar.delegate =自我;
searchBar.showsCancelButton = YES;
searchBar.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth;
*的UIBarButtonItem = customBarItemRight [[[的UIBarButtonItem页头] initWithCustomView:搜索栏]自动释放];
tabBarController.navigationItem.rightBarButtonItem = customBarItemRight;
- (无效)searchBarTextDidBeginEditing:(*的UISearchBar)搜索栏{
searchDisplayController.searchResultsTableView.hidden = NO;
[UIView的animateWithDuration:0.3
动画:^ {
的CGRect newBounds = searchBar.bounds;
newBounds.size.width = 350;
searchBar.bounds = newBounds;
}];
[searchDisplayController SETACTIVE:YES动画:是];
}
解决方案
您不应使用UISearchDisplayController对于这一点,你需要实现动画自定义视图控制器。
I am trying to duplicate the UISearchBar animation seen in mobile Safari. Instead of only moving the left margin, the UISearchBar Expands off the screen and then "jumps" into the proper location. The downsizing is similarly uneven. How can I make this animation even like the UISearchBar in mobile safari?
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];
}
解决方案
You should not use UISearchDisplayController for this, you need to implement animation for your custom view controller.
这篇关于如何让我的UISearchBar在UINavigationBar的使用块动画只调整左边距?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!