显示 UISearchBar“X”在文本字段内与相邻的取消按钮内
我知道我可以将 UISearchBar 的 showsCancelButton 设置为 NO
...直到您点击搜索栏文本字段,然后出现取消按钮反正! (至少对我来说是这样。)
有没有办法在 UISearchBar 文本字段内的圆圈中显示“X”,而不是在其旁边显示单独的“取消”按钮?请注意,此按钮仅在搜索模式处于活动状态时显示,并且与 showsCancelButton 的设置无关。
I know I can set showsCancelButton to NO
for a UISearchBar ... until you tap the search bar text field, and then the cancel button appears anyway! (At least it does for me.)
Is there a way to show the "X" in a circle within the UISearchBar text field vs. having that separate Cancel button show up adjacent to it? Note that this button only appears for me when search mode is active, and this is regardless of the setting for showsCancelButton.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
请尝试此操作。
使用此取消按钮时将不会显示,
try this
when using this cancel button will not shown.
要启用cancelButton,请尝试
searchBar.showsCancelButton = YES;
尝试上面的代码行。
to enable the cancelButton try
searchBar.showsCancelButton = YES;
Try the above lines of code.
如果您使用界面生成器,则很容易显示。默认情况下它就在那里。我在我的应用程序中使用了搜索栏,并且搜索栏文本字段有一个“X”来清除文本字段
if you use interface builder it is ery easy to show.it is there by default.i have used search bar in my app and the searchbartextfield has an "X" to clear the textfield
“X”可能只是为了清除搜索字段而不是取消搜索,因此一旦搜索正在进行,无论showsCancelButton如何,取消按钮都必须保留。
It might be that the "X" is only intended to clear the search field and not to cancel the search, and so the Cancel button must remain once a search is in play, regardless of showsCancelButton.