所以,在我的UILabel子类的awakeFromNib方法中,我有:
let termsArg = "Terms & Conditions"
self.linkText = termsArg
let exampleText = String(format:"By signing up you agree to our %@ and Privacy Policy", termsArg)
let underlinedAttributedString = NSMutableAttributedString(string: exampleText)
self.linkTextRange = (exampleText as NSString).range(of: termsArg)
let attributes = [NSAttributedStringKey.underlineStyle : NSUnderlineStyle.styleSingle]
underlinedAttributedString.addAttributes(attributes, range: self.linkTextRange)
self.attributedText = underlinedAttributedString
但是,我添加这些属性的行最终导致硬崩溃,只有以下内容吐出到控制台:
- [_ SwiftValue _getValue:forType:]:发送到的无法识别的选择器 实例0x60c00005e510
我想知道出了什么问题,因为看来我已经做好了一切。