Last active
December 30, 2024 20:51
-
-
Save Koshimizu-Takehito/70277e0a6d636b5e819f0b9d5e13bf96 to your computer and use it in GitHub Desktop.
HierarchicalShapeStyle
This file contains hidden or 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
import SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
VStack { | |
TextSampleView(style: .foreground) | |
TextSampleView(style: .mint) | |
TextSampleView(style: linearGradient) | |
} | |
.font(.largeTitle) | |
.fontWeight(.heavy) | |
.fontDesign(.monospaced) | |
} | |
var linearGradient: LinearGradient { | |
.init(colors: [.blue, .purple], startPoint: .topLeading, endPoint: .bottomTrailing) | |
} | |
} | |
struct TextSampleView<Style: ShapeStyle>: View { | |
let style: Style | |
var body: some View { | |
VStack(alignment: .leading) { | |
Text("あのイーハトーヴォの") | |
.foregroundStyle(.primary) | |
Text("すきとおった風、") | |
.foregroundStyle(.secondary) | |
Text("祓辻飴葛蝸鯛驢赳曇危箸") | |
.foregroundStyle(.tertiary) | |
Text("1234567890") | |
.foregroundStyle(.quaternary) | |
} | |
.foregroundStyle(style) | |
} | |
} | |
#Preview { | |
ContentView() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment