无法为UISearchBar的框架或边界设置动画

Wot*_*Wot 4 animation uisearchbar ios

我想为UISearchBar的位置设置动画,但是当我更改UISearchBar的帧或边界属性(中心,alpha剂量动画)时,没有动画效果.
这是iOS SDK 4.2,有没有错误?我糊涂了...

Kat*_*ova 9

问题是一些内部搜索栏视图强制调整大小以忽略动画.

这对我有用 -

[UIView animateWithDuration:0.2 animations:^ {
                     [searchBar setFrame:searchBarFrame];
                     [searchBar setNeedsLayout];
                 }];
Run Code Online (Sandbox Code Playgroud)

在哪里searchBarFrame- 是你需要设置的框架(我在搜索栏第一次调整大小之前保存它)