0

I'm trying to put an SF Symbol next to a piece of text that I have, however, I get the error Argument type 'Image' does not conform to expected type '_FormatSpecifiable'

I am fairly new to Xcode and swift UI so basic explanations would be appreciated.

import SwiftUI


struct HaveACodeButton: View {
    var body: some View {

        //NavigationView {

            NavigationLink(destination: CodeLoginPage()) {

                VStack {

                    Spacer()

                    Text("Have a code?")
                        .padding()
                        .foregroundColor(.blue)
                        .font(.callout)

                    Text("\(Image(uiImage: UIImage(named: "arrow.right.circle")!))")
                }
            }
            .edgesIgnoringSafeArea(.horizontal)


        //}
    }
}

struct HaveACodeButton_Previews: PreviewProvider {
    static var previews: some View {
        HaveACodeButton()
    }
}
jjx1223
  • 11
  • 2

2 Answers2

0

Try using Image(systemName: "arrow.right.circle").

It's a little odd, but you actually use an Image View to create them on iOS.

On macOS you can drag the symbol into the quotes on Text(""), but that requires that the user be running Catalina (and I'm not sure if it's the recommended way).

Austin
  • 1,369
  • 1
  • 13
  • 19
0

You are getting that error because Text Does not have an initializer that accepts another View..

If you want to place an image under the 'Have a Code?' Text view, then you can change your VStack to the following:

VStack {
    Spacer()

    Text("Have a code?")
        .padding()
        .foregroundColor(.blue)
        .font(.callout)

    Image(systemName: "arrow.right.circle")
}

Otherwise, if you want to place the Image to the right of the 'Have a Code?' Text view change VStack above to an HStack.

Vlad
  • 932
  • 6
  • 18