Slide 41
Slide 41 text
"UUSJCVUFE4USJOH
JGBWBJMBCMF
\^FMTF\^ͰׅΒΕΔͱܯࠂ͕ग़ͳ͍
var body: some View {
VStack {
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 { ɾɾɾ }
}