ios - 类似于 Whatsapp 的已读状态的双复选标记

标签 ios objective-c swift

如何在 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])

enter image description here

来自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/

相关文章:

ios - 从 iOS 中的所有 3 个麦克风录音

ios - Swift 中的单行 if 语句

objective-c - 是什么导致 iOS 中的 CBCentralManager State Unknown?

ios - IOS 中的 CallKit 扩展

ios - 带有AFAmazonS3Manager + AFNetworking的Amazon s3

objective-c - UILabel 文本被截断

iphone - 扩展 NSManagedObject 实体对象是否安全

ios - 在执行 segue 之前如何检查服务器响应值

ios - 调用另一个 Swift 类中的函数

iOS - UIVIewController 中的 UITableView 不显示所有行 [Swift]