NSAttributedString和布局的奇怪问题

时间:2019-08-16 12:48:41

标签: ios swift

我有一个标签: enter image description here

对于标签,我设置了attributedText:

let greenColor = UIColor.green
let thePrivacyPolicyAttribute = [.underlineStyle: NSUnderlineStyle.single.rawValue, .foregroundColor : greenColor] as [NSAttributedString.Key : Any]
let thePrivacyPolicyAtrStr = NSAttributedString(string: "\(NSLocalizedString("thePrivacyPolicy", comment: ""))", attributes: thePrivacyPolicyAttribute)
let iAgreewithAtrStr = NSAttributedString(string: NSLocalizedString("Iagreewith", comment: ""))
let resultAtrStr = NSMutableAttributedString()
resultAtrStr.append(iAgreewithAtrStr)
resultAtrStr.append(thePrivacyPolicyAtrStr)

privacyPolicyTextLabel.attributedText = resultAtrStr

在所有设备上的结果看起来都很完美,但是在iPhone SE上看起来: enter image description here

我发现问题是在执行privacyPolicyTextLabel.attributedText = resultAtrStr

之后发生的

在其他设备(iPhone 6、6 Plus,X)上看起来很完美: enter image description here

为什么iPhone SE会发生问题以及如何解决?

更新1:

已附加Content Hugging Priority和内容Compression Resistance Priority

enter image description here

0 个答案:

没有答案
相关问题