UISearchBar with statusbar animation transition bug ios7

和自甴很熟 提交于 2019-12-04 10:53:24

I found that

self.navigationController.navigationBar.translucent = YES;

made my animation less buggy

I thinks this is IOS 7 bug. There is an uitableview search example application provided by Apple. And it has same problem while finishing editing search bar. With IOS 6 there is no any problem

Just add a sublayer to the UISearchBar and change the view's background color will make the animation almost perfect

- (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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!