简体   繁体   English

UISearchBar与状态栏动画过渡错误iOS7

[英]UISearchBar with statusbar animation transition bug ios7

I have a problem with UISearchBar animation. 我对UISearchBar动画有问题。

The animation is buggy when the statusbar is on. 状态栏打开时,动画有错误。 Otherwise it is okay. 否则就可以了。 I created the tableview and the searchbar programatically. 我以编程方式创建了tableview和searchbar。 The uisearchbar is in the headerview of a tableview. uisearchbar位于表视图的标题视图中。 It's important that it stays that way. 保持这种状态很重要。 I know its working okay when you use the storyboard. 当您使用情节提要板时,我知道它可以正常工作。

I created a very basic sample project as I think this is the easiest way to show you the problem. 我创建了一个非常基本的示例项目,因为我认为这是向您展示问题的最简单方法。 I have spent several hours to find the solution but I just can't figure it out. 我已经花了几个小时来找到解决方案,但是我无法弄清楚。 Any help would be greatly appreciated. 任何帮助将不胜感激。

Here's a link to the sample project: SearchBarProject ! 这是示例项目的链接: SearchBarProject

I found that 我找到

self.navigationController.navigationBar.translucent = YES;

made my animation less buggy 使我的动画少了越野车

I thinks this is IOS 7 bug. 我认为这是IOS 7错误。 There is an uitableview search example application provided by Apple. Apple提供了一个uitableview搜索示例应用程序。 And it has same problem while finishing editing search bar. 并且在完成编辑搜索栏时也有同样的问题。 With IOS 6 there is no any problem 使用IOS 6不会有任何问题

Just add a sublayer to the UISearchBar and change the view's background color will make the animation almost perfect 只需在UISearchBar上添加一个子层并更改视图的背景颜色,即可使动画几乎完美

- (void) searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller {
    self.view.backgroundColor = RGB(199,199,204);

    self.fixSearchAnimation = [[UIView alloc] initWithFrame:CGRectMake(0, -20,320, 40)];
    self.fixSearchAnimation.backgroundColor = RGB(199,199,204);
    [self.searchController.searchBar addSubview:self.fixSearchAnimation];
    [self.searchController.searchBar sendSubviewToBack:self.fixSearchAnimation];
}
- (void) searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller {
    self.view.backgroundColor = [UIColor whiteColor];
    [self.fixSearchAnimation removeFromSuperview];
}

in slow mode, you can still see a tiny line between the searchbar origin subviews and the new view, but it's not very noticeable for a user, and if that disturb you, you can dig into the view hierarchical of UISearchbar and put the view in the right position. 在慢速模式下,您仍然可以在搜索栏原始子视图和新视图之间看到一条细线,但是对于用户来说并不是很明显,如果这打扰了您,您可以深入研究UISearchbar的视图层次结构并将其放入正确的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM