我是 SwiftUI 新手,我希望重现下图。这是我当前的代码。
VStack(spacing: 6) {
HStack {
Text("Enter your email to sign in or create an")
.font(.system(size: 18))
Text("account.")
.font(.system(size: 18))
.bold()
}
}
这是 Swift 原生
AttributedString
与 markdown 的一个很好的例子。
struct ContentView: View {
var body: some View {
VStack(alignment: .leading, spacing: 6) {
Text("Welcome!")
.font(.largeTitle).bold()
HStack {
Text(attributedPrompt)
.font(.system(size: 18.0))
.padding(.trailing, 100)
}
}
.padding()
}
var attributedPrompt : AttributedString {
return try! AttributedString(markdown: "Enter your email to **sign in** or **create an account**.")
}
}