如何在 UILabel 中通过 unicode 检验标记 (U+2713),没有任何图像
用Unicode做到这一点不是问题,如何使其类似于whatsapp的read status ?如何在两个 unicode 符号之间设置字母间距或删除空格?
最佳答案
您可以使用NSAttributedStringKey.kern
来实现这一点...
let label = UILabel(frame: CGRect(x: 0, y: 0, width: 100, height: 30))
label.backgroundColor = .white
label.attributedText = NSAttributedString(string: "✓✓", attributes: [.kern: -6])
来自Apple's docs ...
The value of this attribute is an
NSNumber
object containing a floating-point value. This value specifies the number of points by which to adjust kern-pair characters. Kerning prevents unwanted space from occurring between specific characters and depends on the font. The value 0 means kerning is disabled. The default value for this attribute is 0.
关于ios - 类似于 Whatsapp 的已读状态的双复选标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52145201/