Home > Blockchain >  How can I change fontWeight of a placeholder in SwiftUI?
How can I change fontWeight of a placeholder in SwiftUI?

Time:04-28

In my SwiftUI project I have a placeholder that I want to be .heavy, but when I try to modify fontWeight it says that fontWeight is define on Text, what should I do?

This is the code:

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

CodePudding user response:

for TextField you use

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