gpt4 book ai didi

ios - 如何使用 Unicode 将自定义符号分配给 UIButton?

转载 作者:可可西里 更新时间:2023-11-01 05:40:54 26 4
gpt4 key购买 nike

我想为 UIButtons 分配一些 Unicode 符号。我尝试了不同的方法,但找不到有效的方法。此屏幕截图显示了我想要实现的目标:

enter image description here

到目前为止我已经尝试过:

 [button setTitle:[NSString stringWithFormat:@"\u27F2"] forState:UIControlStateNormal];

[button setTitle:[NSString stringWithFormat:@"\U27F2"] forState:UIControlStateNormal];

[button setTitle:[NSString stringWithFormat:@"\U+27F2"] forState:UIControlStateNormal];

[button setTitle:[NSString stringWithFormat:@"U+27F2"] forState:UIControlStateNormal];

在所有情况下,我的按钮都显示带框的问号。

enter image description here

任何帮助将不胜感激。谢谢

最佳答案

使用 "\u{27F2}",或者在 obj-c 中:@"\u27F2",获取 Unicode 字符串。如果它没有显示或显示一个问号,那么您使用的字体不支持该字形。然后找到具有该字形(字母)的字体系列。

swift 3.0

let button = UIButton(frame: CGRect(x: 0, y: 0, width: 66, height: 66))
button.setTitle("\u{27F2}", for: [])
button.titleLabel?.font = UIFont(name:"AvenirNext-UltraLight", size: 46)

objective-C :

[button setTitle:@"\u27F2" forState:UIControlStateNormal];
button.titleLabel.font = [UIFont fontWithName:@"AvenirNext-UltraLight" size:21.0];

关于ios - 如何使用 Unicode 将自定义符号分配给 UIButton?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26437721/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com