Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created January 16, 2020 12:09
Show Gist options
  • Save sturdysturge/fa3597066f2edff5e35174b0e2253560 to your computer and use it in GitHub Desktop.
Save sturdysturge/fa3597066f2edff5e35174b0e2253560 to your computer and use it in GitHub Desktop.
SwiftUIDocumentationMoreTextModifiers
struct ContentView: View {
var body: some View {
VStack {
Text("Foreground colour")
.foregroundColor(.red)
Text("background colour")
.background(Color.red)
Group {
Text("background colour with padding")
.background(Color.red)
.padding()
}
.border(Color.red, width: 1)
Text("Bold")
.bold()
Text("Italics")
.italic()
Text("Baseline offset")
.baselineOffset(20)
.border(Color.red, width: 1)
Text("Tracking")
.tracking(20)
Text("Kerning")
.kerning(-1)
Group {
Text("Underline")
.underline()
Text("Blue Underline")
.underline(color: .blue)
Text("Custom Underline")
.redUnderline()
}
Group {
Text("Strikethrough")
.strikethrough()
Text("Red Strikethrough")
.strikethrough(color: .red)
Text("Custom Strikethrough")
.greenStrikethrough()
}
}
}
}
extension Text {
func greenStrikethrough() -> some View {
return self.strikethrough(color: .green)
}
func redUnderline() -> some View {
return self.underline(true, color: .red)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment