gpt4 book ai didi

ios - 如何更改字符 nsAttributedString 的对齐方式

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

<分区>

这就是我想要实现的。

enter image description here

我使用了一个 attributedString,获取了字符 $ 的范围并将属性应用到它,如下所示:

let str = "$4"
let r1 = str.range(of: "$")!
let n1 = NSRange(r1, in: str)
let atrStr = NSMutableAttributedString(string: str)
atrStr.addAttributes([NSAttributedStringKey.font : UIFont.systemFont(ofSize: 25)], range: n1)
atrStr.addAttributes([NSAttributedStringKey.foregroundColor : UIColor.lightGray], range: n1)
lbl.attributedText = atrStr

但是结果是

enter image description here

如何将特定字符的对齐方式从下到上更改?

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