iPhone UISearchBar 动画到顶部
有很多应用程序的搜索栏在活动时向上移动,在不活动时向下移动。苹果提供了一个可与 IB 配合使用的示例代码,但我如何以编程方式实现此行为?大多数情况下,它与导航栏相结合,导航栏移出屏幕以代替搜索栏
There are lots of apps where the searchbar moves upwards if active and moves down when it is inactive. There is a sample code from apple available which works with IB, but how can I achieve this behavior programmatically? Mostly it is combined with a navigationbar which moves out of the screen in replace with the searchbar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就我个人而言,我最终在搜索开始时使用
[self.navigationController setNavigationBarHidden:YESAnimated:YES];
,然后只需执行[self.navigationController setNavigationBarHidden:NOanimated:YES];
code> 搜索完成后。Personally, I ended up using
[self.navigationController setNavigationBarHidden:YES animated:YES];
when the search begins and then just do[self.navigationController setNavigationBarHidden:NO animated:YES];
once the search is done.当搜索栏成为第一响应者时,它会自行动画。你可以调用[searchBar成为FirstResponder];或类似的东西,检查文档。
When the search bar becomes first responder it will animate itself. You can call [searchBar becomeFirstResponder]; or something like that, checkpoint the docs.