开发者

How do I make UISearchBar in a UINavigationBar resize only the left margin using a block animation?

开发者 https://www.devze.com 2023-02-08 11:59 出处:网络
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 \"ju开发者_StackOverflow社区mps\" into

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 "ju开发者_StackOverflow社区mps" 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号