我对 textview 上的 "Re-Send?" 文本换行有疑问
I have problem with "Re-Send?" text wrapping on textview
"I have label that text is "没有收到验证码?重新发送?”,这里我使用了自动换行。但是在下一行展开 "Send?" 时,我总是需要 "Re-Send?" 在一起,要么在“?”之后(不接收验证码?重新发送?)或在下一行 "Re-send?"。,有人可以建议我如何解决这个问题吗?
如果我使用 "Re_Send",那么它会出现在下一行,但是如果我使用 "Re-Send",这个词就会被拆分。
let attributeText = NSMutableAttributedString(string: "Don't you get
verificationcode in your email Inbox? ", attributes:
[NSAttributedString.Key.foregroundColor: UIColor.red,
NSAttributedString.Key.font: UIFont.systemFont(ofSize:
22),NSAttributedString.Key.paragraphStyle: style])
attributeText.append(NSAttributedString(string: " Re-Send ",
attributes: [NSAttributedString.Key.foregroundColor: UIColor.green,
NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 22)]))
let linkRange = attributeText.mutableString.range(of: " Re-Send ")
attributeText.addAttribute(NSAttributedString.Key.link, value:
linkKey, range: linkRange)
txtview.attributedText = attributeText
txtview.textContainer.lineBreakMode = NSLineBreakMode.byWordWrapping
txtview.textAlignment = .center
我需要它应该是 "Don't you get verificationcode in your email Inbox? Re-Send?" 或“您的电子邮件收件箱中没有收到验证码吗?
重发? " 。(取决于我的屏幕长度)。
使用 ‑
(U+2011 不间断连字符)代替 -
(U+002D 连字符减号)。
attributeText.append(NSAttributedString(string: " Re‑Send ",
或
attributeText.append(NSAttributedString(string: " Re\u{2011}Send ",
let string = "\u{2011}"
attributeText.append(NSAttributedString(string: " Re\(string)Send ",
attributes: [NSAttributedString.Key.foregroundColor: UIColor.green,
NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 22)]))
let linkRange = attributeText.mutableString.range(of: " Re\(string)Send ")
attributeText.addAttribute(NSAttributedString.Key.link, value: linkKey, range:
linkRange)
"I have label that text is "没有收到验证码?重新发送?”,这里我使用了自动换行。但是在下一行展开 "Send?" 时,我总是需要 "Re-Send?" 在一起,要么在“?”之后(不接收验证码?重新发送?)或在下一行 "Re-send?"。,有人可以建议我如何解决这个问题吗?
如果我使用 "Re_Send",那么它会出现在下一行,但是如果我使用 "Re-Send",这个词就会被拆分。
let attributeText = NSMutableAttributedString(string: "Don't you get
verificationcode in your email Inbox? ", attributes:
[NSAttributedString.Key.foregroundColor: UIColor.red,
NSAttributedString.Key.font: UIFont.systemFont(ofSize:
22),NSAttributedString.Key.paragraphStyle: style])
attributeText.append(NSAttributedString(string: " Re-Send ",
attributes: [NSAttributedString.Key.foregroundColor: UIColor.green,
NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 22)]))
let linkRange = attributeText.mutableString.range(of: " Re-Send ")
attributeText.addAttribute(NSAttributedString.Key.link, value:
linkKey, range: linkRange)
txtview.attributedText = attributeText
txtview.textContainer.lineBreakMode = NSLineBreakMode.byWordWrapping
txtview.textAlignment = .center
我需要它应该是 "Don't you get verificationcode in your email Inbox? Re-Send?" 或“您的电子邮件收件箱中没有收到验证码吗? 重发? " 。(取决于我的屏幕长度)。
使用 ‑
(U+2011 不间断连字符)代替 -
(U+002D 连字符减号)。
attributeText.append(NSAttributedString(string: " Re‑Send ",
或
attributeText.append(NSAttributedString(string: " Re\u{2011}Send ",
let string = "\u{2011}"
attributeText.append(NSAttributedString(string: " Re\(string)Send ",
attributes: [NSAttributedString.Key.foregroundColor: UIColor.green,
NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 22)]))
let linkRange = attributeText.mutableString.range(of: " Re\(string)Send ")
attributeText.addAttribute(NSAttributedString.Key.link, value: linkKey, range:
linkRange)