Last active
July 13, 2023 06:39
-
-
Save gaussbeam/382117a9180df54ea78a09331a671035 to your computer and use it in GitHub Desktop.
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 FontStyleSampleView: View { | |
private var fontStyles = FontStyle.allCases | |
var body: some View { | |
List(fontStyles, id: \.self) { style in | |
Text(style.rawValue) | |
.fontStyle(style) | |
.foregroundColor(.black) | |
Text(displayString(from: style)) | |
.font(.system(size: style.estimatedDefaultPointSize)) | |
.fontWeight(style.weight) | |
.foregroundColor(.gray) | |
} | |
} | |
private func displayString(from style: FontStyle) -> String { | |
"\(style.rawValue), estimated: \(style.estimatedDefaultPointSize) pt" | |
} | |
} | |
struct FontStyleSampleView_Previews: PreviewProvider { | |
static var previews: some View { | |
FontStyleSampleView() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment