如何在 UILabel 中显示表达程度? (Swift)

How can i show degree of expression in UILabel? (Swift)

我有一个显示表达式的标签:

(x+y)

但我想在这样的标签中显示它:

(x+y)^2

(但是有学位,我这里做不到,因为我声望太低,无法插入图片)

所以,我想在UIlabel中显示表情的程度。 可以使用单个 UILabel 吗?

您可以使用两个上标 \u00B2 的 Unicode 字符,它总是 \u 后跟字符代码。

NSString *equation = [NSString stringWithFormat:@"(x+y)%@", @"\u00B2"];

Swift:

var equation = NSString(format:"(x+y)%@",  "\u{00B2}") as String

结果:

http://unicode-table.com/en/

Strings and Characters(Apple iOS 开发者库)

Strings in Swift

我认为您正在寻找权力,例如(x + y)⁹。 为此,您必须使用 unicodes。

你可以从这里获取 unicodes 字符列表; http://www.fileformat.info/info/unicode/category/No/list.htm

在代码中,您将使用;

print("(x+y)\u{00B2}");