如何在SwiftUI中改变占位符的font - weight ?



在我的SwiftUI项目中,我有一个占位符,我想是。heavy,但当我试图修改fontWeight它说,fontWeight是在文本上定义的,我该怎么办?

这是代码:

TextField("", text: $MyModel.name[0])
.placeholder(when: MyModel.name[0].isEmpty) {
Text(player1)
.font(Font.custom("Life Savers", size: 26))
.fontWeight(.bold)
}
.font(Font.custom("Life Savers", size: 26))
//here it doesn't let me change the fontWeight to heavy

对于TextField使用

.font(Font.custom("Life Savers", size: 26).weight(.heavy))

最新更新