UITextView – can't set underline or strikethrough attributes on text?

前端 未结 1 1294
情话喂你
情话喂你 2020-12-11 15:31

I\'m getting runtime failures whenever I try to set underline or strikethrough attributes on the attributedText of a UITextView. Other properties, like font and background c

相关标签:
1条回答
  • 2020-12-11 15:52

    Your underline style is invalid. Change this line:

    let underlineAttribute = 
        [NSAttributedStringKey.underlineStyle: NSUnderlineStyle.styleSingle]
    

    to this:

    let underlineAttribute = 
        [NSAttributedStringKey.underlineStyle: NSUnderlineStyle.styleSingle.rawValue]
    

    Result:

    0 讨论(0)
提交回复
热议问题