if #available(iOS 15, *) { Text(attributedString) } else { AttributedText { Text("Foo") Text(" ") Text("Bar") .foregroundColor(.red) Text(" ") Text("Baz") .font(.title) Text(" ") Text("Qux") .font(.footnote) .foregroundColor(.green) Text(" ") Text("Quux") } } } } @available(iOS, deprecated: 15.0, obsoleted: 16.0, message: "Use `Text` with `AttributedString`") struct AttributedText: View { typealias Body = Text var text: Text init(@Builder builder: () -> Text) { text = builder() } var body: Text { text } } @available(iOS, deprecated: 15.0, obsoleted: 16.0, message: "Use `Text` with `AttributedString`") extension AttributedText { @resultBuilder enum Builder { ɾɾɾ } }