iOS - How to animate (dis)appereance of scope bar in UISearchBar?
-
19-06-2021 - |
سؤال
Well I read this article, however the scope bar just shows instantly, no animation.
المحلول
This should work:
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {
[searchBar setShowsCancelButton:YES animated:YES];
searchBar.showsScopeBar = YES;
return YES;
}
- (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar {
[searchBar setShowsCancelButton:NO animated:YES];
[searchBar sizeToFit];
searchBar.showsScopeBar = NO;
return YES;
}
Remember to associate the UISearchBar delegate.
لا تنتمي إلى StackOverflow