禁用UISearchBar

Tom*_*Tom 17 xcode objective-c uisearchbar ios ios5

我有一个 - 我希望 - 非常简单的问题:如何在IOS5中禁用UISearchBar以避免用户交互?我找不到setEnabled或类似的东西......

谢谢!

Con*_*ltz 44

你有没有尝试过:

[searchBar setUserInteractionEnabled:NO];
Run Code Online (Sandbox Code Playgroud)


fli*_*zit 15

除了设置用户交互之外,我还调整了alpha值,使外观独一无二.

searchbar.alpha = .75;
Run Code Online (Sandbox Code Playgroud)


Maz*_*ser 6

试试这个

// Normal 
self.searchDisplayController.searchBar.userInteractionEnabled = YES;
self.searchDisplayController.searchBar.translucent = YES;
self.searchDisplayController.searchBar.searchBarStyle = UISearchBarStyleDefault;
self.searchDisplayController.searchBar.backgroundColor = [UIColor clearColor];

// Faded out
self.searchDisplayController.searchBar.userInteractionEnabled = NO;
self.searchDisplayController.searchBar.translucent = NO;
self.searchDisplayController.searchBar.searchBarStyle = UISearchBarStyleMinimal;
self.searchDisplayController.searchBar.backgroundColor = [UIColor lightGrayColor];
Run Code Online (Sandbox Code Playgroud)