Home > Mobile >  SwiftUI by add style on button, text stop showing on Xcode preview
SwiftUI by add style on button, text stop showing on Xcode preview

Time:09-01

I am trying to add style to the button but after adding style my text on button stops showing in XCode preview.

 Button {
            } label: {
              Text("[email protected]")
            }.buttonStyle(.borderedProminent).tint(  .primary)

I also try

Button {
        } label: {
          Text("[email protected]")
        }.buttonStyle(.borderedProminent).tint( .mint)

please check screenshot

CodePudding user response:

It is because of the email address, a link will be detected. To achieve the desired behavior, add verbatim to your Text()

Button {
} label: {
    HStack() {
        Text(verbatim: "[email protected]")
    }
}.buttonStyle(.borderedProminent).tint(  .primary)

link within text

  • Related