xcode 如何将箭头放入 UILabel
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14715872/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to put an arrow into a UILabel
提问by OnkaPlonka
Hi I'm trying to put an arrow into a UILabel's text but it is not working. I'm trying the following code
嗨,我正在尝试将箭头放入 UILabel 的文本中,但它不起作用。我正在尝试以下代码
NSString *labeltext = @"?";
label.text = labeltext;
But that makes the app crash!
但这会使应用程序崩溃!
(if you go to the edit menu and go to special characters then it is the 10th rightwards arrow)
(如果您转到编辑菜单并转到特殊字符,则它是第 10 个向右箭头)
.
.
Thanks for your help in advance
提前感谢您的帮助
回答by nsgulliver
Code should be working by just writing the special character directly in the code as written in the question also
代码应该通过直接在代码中编写特殊字符来工作,如问题中所写
label.text=@"?";
but in case it is not working then there are alternative ways to print the special characters in IOS, You need to use Unicode character of this sign , check out this page codesand after getting the code just do like as follows
但是如果它不起作用,那么在 IOS 中有其他方法可以打印特殊字符,您需要使用此符号的 Unicode 字符,查看此页面代码并在获取代码后执行如下操作
UniChar ucode = 0x2794;
NSString *codeString = [NSString stringWithCharacters:&ucode length:1];
[label setText:codeString];
OR Just write directly like as follows
或者直接写成如下
label.text=@"\u2794"; // this is the unicode for right arrow
in Swift:
在斯威夫特:
lable.text="\u{2794}"