【问题标题】:How do I make UISearchBar in a UINavigationBar resize only the left margin using a block animation?如何使用块动画使 UINavigationBar 中的 UISearchBar 仅调整左边距?
【发布时间】:2011-02-01 19:43:21
【问题描述】:

我正在尝试复制在移动 Safari 中看到的 UISearchBar 动画。 UISearchBar 不只是移动左边距,而是从屏幕上展开,然后“跳”到正确的位置。缩小规模同样不均衡。我怎样才能使这个动画甚至像移动 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];
}

【问题讨论】:

    标签: objective-c ios animation uisearchbar


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-02
      • 1970-01-01
      • 2011-08-26
      • 1970-01-01
      • 1970-01-01
      • 2012-08-25
      • 2017-12-20
      • 2014-11-24
      相关资源
      最近更新 更多