Created
January 16, 2020 12:09
-
-
Save sturdysturge/fa3597066f2edff5e35174b0e2253560 to your computer and use it in GitHub Desktop.
SwiftUIDocumentationMoreTextModifiers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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