UNI code在按钮标题以x code [英] Unicode in button title in XCode

查看:212
本文介绍了UNI code在按钮标题以x code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示一个按钮作为标题希腊字母PI(UNI code \\ u03C0)。
当我尝试使用拖放图形化编辑器,守信用\\ u03C0显示设置标题。
是否有某种方式来设置UNI code文本在图形编辑器,或者我需要以编程方式做到这一点?
如果非要以编程方式做到这一点,什么是做到这一点的最好方法是什么?

I'm trying to display the greek letter pi (unicode \u03C0) on a button as the title. When I try to set the title using drag'n'drop graphical editor, the word "\u03C0" shows. Is there some way to set unicode text in the graphical editor, or do I need to do it programmatically? If I have to do it programmatically, what is the best way to do this?

我希望有人能帮助我这个问题,因为我的谷歌搜索一直是徒劳的。

I hope somebody can help me with this, since my google searches have been futile.

我使用的iOS 5.0
X code版本4.2.1

I use iOS 5.0 XCode version 4.2.1

推荐答案

您可以使用Interface Builder来在其标题任何统一code字创建一个按钮。有几种方法

Interface Builder

You can use Interface Builder to create a button with any Unicode character in its title. There are several methods.


  • 作为汤米建议,你可以输入选项-P插入一个希腊字母PI。

  • 作为汤米也建议,可以使用键盘显示程序从输入菜单查看可以使用的选项和控制按键可以键入哪些字符。您也可以preSS在键盘查看器屏幕上的键盘按钮,这些字符插入到当前文本字段(如您的按钮的标题)。

  • 您可以使用<击>字符浏览器表情和放大器;从编辑菜单(也可能输入菜单)的底部符号窗口中找到其他字符。双击表情和放大器一种性格;符号将其插入到当前文本字段。单击该窗口右上角的图标基本和高级模式之间切换。

  • 您可以启用统一code十六进制输入源(系统preferences>语言和放大器;文本>输入源),并从输入菜单中选择。然后你就可以按下Option和输入四个十六进制数字输入一个统一code字符。例如,你可以按住选项并输入03c0进入希腊字母PI。

  • 如果您发现该字符其他地方,如在网页上,你可以从源在Interface Builder复制,然后粘贴。

  • As Tommy suggested, you can type Option-P to insert a greek character pi.
  • As Tommy also suggested, you can use the Keyboard Viewer from the Input menu to see what characters you can type using the option and control keys. You can also press the on-screen keyboard buttons in the keyboard viewer to insert those characters into the current text field (such as your button's title).
  • You can use the Character Viewer Emoji & Symbols window from bottom of the Edit menu (and possibly also the Input menu) to find other characters. Double-clicking a character in Emoji & Symbols will insert it into the current text field. Clicking the icon in the top right of this window toggles between basic and advanced modes.
  • You can enable the Unicode Hex Input source (System Preferences > Language & Text > Input Sources) and select it from the Input menu. Then you can hold Option and type four hex digits to enter a Unicode character. For example, you can hold Option and type "03c0" to enter the greek character pi.
  • If you find the character somewhere else, like on a web page, you can copy it from the source and then paste it in Interface Builder.

如果您要设置按钮的标题在Objective-C,它看起来像这样:

If you want to set the button's title in Objective-C, it looks like this:

self.myButton.titleLabel.text = @"π or \u03c0";

您可以使用任何的方法我上面列出类型的Uni code字符到您的权利来源$ C ​​$ C,也可以使用 \\ü的UNI code转义序列跟四个十六进制数字。

You can type Unicode characters right into your source code using any of the methods I listed above, or you can use a Unicode escape sequence of \u followed by four hex digits.

统一字符code面0(基本多文种平面或BMP)以外需要四个以上的十六进制数字。对于他们来说,使用 \\ U 随后的8个十六进制数字。例如:

Characters outside of Unicode plane 0 (the Basic Multilingual Plane, or BMP) require more than four hex digits. For them, use \U followed by eight hex digits. Example:

这篇关于UNI code在按钮标题以x code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆