如何在 TextField swiftUI 中加粗文本? [英] How to bold text in TextField swiftUI?
本文介绍了如何在 TextField swiftUI 中加粗文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SwiftUI 中的文本字段没有内置字体粗细修饰符(XCODE:11.2.1).如何在不将 UITextField 扩展为 UIViewRepresentable 的情况下引入字体粗细?
There is no builtin font-weight modifier for textfield in SwiftUI (XCODE: 11.2.1). How can we introduce font-weight without extending UITextField as UIViewRepresentable?
推荐答案
import SwiftUI
struct ContentView: View {
@State var TextValue: String = "Hello"
var body: some View {
VStack {
TextField("placeholder", text: $TextValue)
.padding(.horizontal, 50)
.font(.system(size: 30, weight: .heavy, design: .default))
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
这篇关于如何在 TextField swiftUI 中加粗文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文