skip to Main Content

I am getting the following error message when I add the Text modifier Bold;

Xcode error message

Can anyone help?

3

Answers


  1. Chosen as BEST ANSWER

    I used the fontWeight(.bold) modifier immediately after the Text component. I am using SwiftUI 3.0 so I think that's why .bold isn't a member of Text()


  2. The sequence is a matter for SwiftUI. .bold() is modifier of Text so write .bold() modifier after Text statement.

    Return type of .padding() and .foregroundColor(.red) is View.

    Text("SomeText")
        .bold()
        .padding()
        .foregroundColor(.red)
    
    Login or Signup to reply.
  3. In SwiftUI 3 .bold() is a modifier of the font itself.

    Text("Stephen Learmonth")
       .padding()
       .font(.title.bold())
       .foregroundColor(.white)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search