- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
如何在 UITextField
的左侧添加放大镜图标?
我找到了类似问题的答案 here但我无法将其转换为 swift。
答案:
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];Edit: For plain look that fits iOS 7 style, add Unicode variation selector \U000025B6.
我的代码:
let searchIconView = UILabel()
// Doesn't work: searchIconView.text = NSString.init(UTF8String: "\xF0\x9F\x94\x8D")
searchIconView.sizeToFit()
searchTextField.leftView = searchIconView
searchTextField.leftViewMode = .Always
最佳答案
您是否有特定原因尝试将图标添加为 UTF8String?如果你有一个放大镜图标作为 PNG 图片,你可以像这样使用 UITextField 的“leftView”属性;
let imageView = UIImageView()
let magnifyingGlassImage = UIImage(named: "magnifyingGlass")
imageView.image = magnifyingGlassImage
//arrange the frame according to your textfield height and image aspect
imageView.frame = CGRect(x: 0, y: 5, width: 45, height: 20)
imageView.contentMode = .ScaleAspectFit
txtField.leftViewMode = .Always
txtField.leftView = imageView
关于ios - 将 C 转换为 Swift : Add magnifying glass icon to UITextField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35056705/
我正在开发一个 Android 项目,其中有一个抽屉导航,其中显示了 GroupSection 对象的列表。所有 GroupSection 对象都包含一个部分图标。抽屉图标由 TypedArray 和
$('a[class*=icon-]').append(""); 使用我现在拥有的代码,我可以转动: 进入 但我想将选定的类“icon-edit”附加到跨度类中。因为我想要这样的东西: var
我正在建立一个网站,我希望在视觉上有一排字体很棒的图标看起来具有相同的高度。这也意味着我希望他们都坐在同一基线上。 由于图标的性质是具有不同纵横比的不同形状,当您将具有相同字体大小或 fa-2x(等)
我有两个图标,其中一个图标为 .gif,另一个图标为 .png。所以我想组合这些图标,将动画图标放在另一个图标之上。 此代码适用于静态图标,但在放置动画图标时,它不会打印动画。 public clas
当我在控制台中运行 gatsby develop 时,会出现此错误: ERROR #11331 PLUGIN Invalid plugin options for "gatsby-plugin-ma
在适用于iPhone的iOS 7上,有一个新的应用程序图标大小:120x120。我使用此尺寸来创建iOS 7专用图标。在iOS 6上,它将自动采用“旧” 114x114图标,在iOS 7上,它将采用新
我的简单问题是:是否可以将图标组件内的文本居中,我尝试像 child 一样传递文本,但它不起作用?还有其他解决方案吗?我知道可能的解决方案是使用 position: 'absolute' 但还有其他方
我有这个代码: if(seatE1.getIcon() == particular icon) { // do something } 我不知道在特定图标中写什么。我应该写我想要的图标的路径还
在调用 System.Drawing.Icon.ToBitmap() 创建图像后,是否可以安全地处理原始 Icon? 最佳答案 该方法将 Icon 转换为新的 Bitmap 对象,因此不会有从 Bit
这个图钉图标的名称是什么? 最佳答案 现在 Material Icon 中提供了准确的图标。 图标名称:push_pin 图标网址:https://material.io/resources/icon
数据如下: df % ggplot(aes(label = parts, values = values)) + geom_pictogram(n_rows = 10, aes(color =
我正在为 VSCode 编写扩展。在 WebviewPanel 中,我需要显示来自文件图标主题的文件扩展名图标。是否有从文件图标主题中获取图标的功能? 最佳答案 我也在研究这个。我还没有答案,但到目前
我正在组装一个通用应用程序,并且我的项目中有图标,但是我不断从编译器收到关于Icon.png的警告。 我按照http://developer.apple.com/library/ios/#qa/qa2
我正在组装一个通用应用程序,并且我的项目中有图标,但是我不断从编译器收到有关Icon.png的警告。 我按照http://developer.apple.com/library/ios/#qa/qa2
我下载了“Office 2010 Add-In: Icons Gallery ”,这是一个 docx 文件,其中有两个包含图标的后台选项卡。 如何提取图标或在我的应用程序中使用它们? 最佳答案 我在
我正在开发一个 MacOS 应用程序,该应用程序应显示应用程序图标。对于某些应用程序,它可以工作,对于某些应用程序,它不能。 Notes.app 是我没有获得应用程序图标图像的应用程序。 let ic
我只是在Android Studio中创建了一个模板项目,我没有更改一行代码(DrawerLayout模板项目)。 但是,我发现用于显示导航 fragment 的单击图标始终是向左箭头,即使在代码中它
我正在尝试找出如何使用 xpath 通配符来获取网站图标: $doc = new DOMDocument(); $doc->strictErrorChecking = FALSE; $doc->loa
Mobile Safari对于比传统 16x16 分辨率更高的图标,需要使用以下咒语: 但是,Firefox 需要使用 HTML5 syntax ,例如: 现在,我的期望是可以将它们组合成一行
我目前为动态创建的 QPushButton 使用以下样式表属性 string mystyle = "QPushButton { border: 1px solid #8f8f91; border-
我是一名优秀的程序员,十分优秀!