Post

Replies

Boosts

Views

Activity

SwiftUI AttributedString not working attachment
I want to present image with his custom modifiers in swiftui with iOS 15 but it does not, what is wrong in this code ? @available(iOS 15, *) func setupLabel() -> AttributedString { var title = AttributedString(text ?? "") var container = AttributeContainer() container.foregroundColor = .red let imageAttachment = NSTextAttachment() imageAttachment.image = UIImage(named: "star") imageAttachment.bounds = CGRect(x: 0, y: 0, width: 20, height: 20) container.attachment = imageAttachment title.mergeAttributes(container) return title } foregroundColor works but image doesn't display.
1
2
914
Jan ’23