AttributedText cannot wrap automatically when image and text are mixed
#420 ouverte le 28 avr. 2023
Métriques du dépôt
- Stars
- (8 002 étoiles)
- Métriques de merge PR
- (Aucune PR mergée en 30 j)
Description
AttributedText cannot wrap automatically
AttributedText(getAttributedString(text: text)) .font(.pfRegular(size: 12)) .foregroundColor(.globeBlack) .environment(.lineLimit, 2) .environment(.lineBreakMode, .byWordWrapping) .environment(.lineSpacing, 3) .frame(width: appWidth - 80, alignment: .leading)
func getAttributedString(text: String) -> NSAttributedString { let att = NSMutableAttributedString(string: text + " ") att.setAttributes([.font: UIFont.pfRegular(size: 12)], range: NSRange(location: 0, length: text.count)) att.setAttributes([.foregroundColor: UIColor.globeBlack], range: NSRange(location: 0, length: text.count)) let tach = NSTextAttachment(image: UIImage.xin ?? UIImage()) tach.bounds = CGRectMake(0, -2, 36, 15) let imageAtt = NSAttributedString(attachment: tach) att.insert(imageAtt, at: att.length) return att }