lixiang1994 / AttributedString

基于Swift插值方式优雅的构建富文本, 支持点击长按事件, 支持不同类型过滤, 支持自定义视图等.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

点击事件崩溃

FPJack opened this issue · comments

commented

adjustsFontSizeToFitWidth = true 的时候 一行展示不下的时候 文字里面有点击部分点击会崩溃

commented

@FPJack 相关代码发一下 我复现看看

commented
    let label = UILabel.init(frame: CGRect(x: 50, y: 100, width: 200, height: 20))
    view.addSubview(label)
    label.adjustsFontSizeToFitWidth = true
    let attr1 = ASAttributedString(string: "I have read and agree the ",.font(.systemFont(ofSize: 10)),.foreground(.black))
    let attr2 = ASAttributedString(string: "User Agreement ", .font(.systemFont(ofSize: 10)),.foreground(.orange),.action(ASAttributedString.Action(highlights: [.foreground(.orange.withAlphaComponent(0.5))]) { _ in

    }))
    let attr3 = ASAttributedString(string: "and ",.font(.systemFont(ofSize: 10)),.foreground(.black))
    let attr4 = ASAttributedString(string: "Privacy Policy ",.font(.systemFont(ofSize: 10)),.foreground(.orange),.action(ASAttributedString.Action(highlights: [.foreground(.orange.withAlphaComponent(0.5))]) { _ in
    }))
    label.attributed.text = attr1 + attr2 + attr3 + attr4
commented

已修复 3.3.5