UISearchBar在UINavigationControllers的导航栏(像google currents for



在当前的Google Currents iOS应用程序(2013年3月30日)中,右上角有一个搜索按钮。如果你点击它,按钮会移动到左边,一个文本框会从右边"生长"出来。在同一动画中,其他按钮被移出左侧。

我的问题是:你如何实现这样的行为?是否有可能实现这与UINavigationController(和UISearchBar/UISearchDisplayController)和其他默认的iOS控件或谷歌写了自己的导航控制器?

你所要做的就是使用UIView动画并拓宽搜索栏的框架。你必须以同样的方式减少它…

[UIView animateWithDuration:0.8 
                  delay:0.0
                options:UIViewAnimationOptionBeginFromCurrentState
             animations:^{
                 searchFrame.size.width += 300;
                 searchbar.frame = searchFrame;
             }
             completion:nil];

最新更新