如何在特定行计算UILabel的文本长度?

时间:2017-07-22 10:04:49

标签: ios uilabel

我有一个非常简单的标签。像这样:

    let label = UILabel()
    label.numberOfLines = 3
    label.text = "hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!"
    label.snp.makeConstraints { (make) in
        make.left.top.equalToSuperview().offset(30)
        make.right.equalToSuperview().offset(30)
    }
    addSubview(label)

我已经分配了label.numberOfLines = 3,现在我想知道第三行的文本长度。我怎么计算呢?感谢

0 个答案:

没有答案