Bur*_*ala 18
上面提供的解决方案可能随着新的iOS版本而改变.这是一个更好的方法:
[searchBar setValue:@"customString" forKey:@"_cancelButtonText"];
Run Code Online (Sandbox Code Playgroud)
Swift等同于Burhanuddin Sunelwala的答案为我做了诀窍!
self.searchBar.setValue("custom string", forKey: "cancelButtonText")
Run Code Online (Sandbox Code Playgroud)
感谢Burhanuddin Sunelwala让我朝着正确的方向前进!
您可以使用此更改搜索栏中的"取消"按钮 -
for (UIView *view in searchBar.subviews)
{
for (id subview in view.subviews)
{
if ( [subview isKindOfClass:[UIButton class]] )
{
[subview setEnabled:YES];
UIButton *cancelButton = (UIButton*)subview;
[cancelButton setTitle:@"hi" forState:UIControlStateNormal];
NSLog(@"enableCancelButton");
return;
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7942 次 |
| 最近记录: |