Search code examples
swiftxcodeswiftuisf-symbols

How to create an SF Symbol Properly?


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()
    }
}

Solution

  • 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).