Skip to content

Instantly share code, notes, and snippets.

@Koshimizu-Takehito
Created July 15, 2024 04:19
Show Gist options
  • Save Koshimizu-Takehito/70277e0a6d636b5e819f0b9d5e13bf96 to your computer and use it in GitHub Desktop.
Save Koshimizu-Takehito/70277e0a6d636b5e819f0b9d5e13bf96 to your computer and use it in GitHub Desktop.
HierarchicalShapeStyle
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