Skip to content

Instantly share code, notes, and snippets.

@alemohamad
Last active November 21, 2023 12:33
Show Gist options
  • Save alemohamad/865f1d575e0637af83e9703beda24015 to your computer and use it in GitHub Desktop.
Save alemohamad/865f1d575e0637af83e9703beda24015 to your computer and use it in GitHub Desktop.
Furigana concept for SwiftUI
import SwiftUI
struct ContentView: View {
var body: some View {
HStack(spacing: 0) {
FuriganaView(moji: "振", furigana: "ふ")
FuriganaView(moji: "り")
FuriganaView(moji: "仮名", furigana: "がな")
}
}
}
#Preview {
ContentView()
}
struct FuriganaView: View {
let moji: String
var furigana: String = " "
var body: some View {
VStack(alignment: .center, spacing: 0) {
Text(furigana)
.kerning(1.5)
.font(.body)
.foregroundStyle(.gray)
Text(moji)
.font(.title)
}
}
}
#Preview {
FuriganaView(moji: "漢字", furigana: "かんじ")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment