在哪里可以获得UISearchBar中使用的放大镜图标? [英] Where can I get the magnifying glass icon used in UISearchBar?
本文介绍了在哪里可以获得UISearchBar中使用的放大镜图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 UITextField
作为 UISearchBar
替换和窃取放大镜图标从原始 UISearchBar
用这个疯狂的代码:
I'm using UITextField
as a UISearchBar
replacement and "stealing" the magnifying glass icon from the original UISearchBar
with this crazy code:
UISearchBar *originalSearchBar = [[UISearchBar alloc] init];
for (UIView *searchBarSubview in [originalSearchBar subviews]) {
if([searchBarSubview isKindOfClass:[UITextField class]]) {
UITextField *textField = (UITextField *)searchBarSubview;
[_textField setLeftView:[textField leftView]];
[_textField setLeftViewMode:UITextFieldViewModeAlways];
}
}
正如你可能已经猜到的,我不想要使用我自己的位图。
As you've probably guessed, I don't want to use my own bitmap.
在Cocoa中有没有更容易访问的放大镜图标?
Isn't there an easier accessible magnifying glass icon somewhere in Cocoa?
推荐答案
所以,这里是unicode字符的代码:
So, here's the code with the unicode character:
UILabel *magnifyingGlass = [[UILabel alloc] init];
[magnifyingGlass setText:[[NSString alloc] initWithUTF8String:"\xF0\x9F\x94\x8D"]];
[magnifyingGlass sizeToFit];
[textField setLeftView:magnifyingGlass];
[textField setLeftViewMode:UITextFieldViewModeAlways];
编辑:适合iOS 7风格的纯粹外观,选择器 \U000025B6
。
For plain look that fits iOS 7 style, add Unicode variation selector \U000025B6
.
这篇关于在哪里可以获得UISearchBar中使用的放大镜图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文