0

我正在尝试在我拥有的一段文本旁边放置一个 SF 符号,但是,我得到了错误 Argument type 'Image' does not conform to expected type '_FormatSpecifiable'

我对 Xcode 和 swift UI 相当陌生,因此将不胜感激基本解释。

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

2 回答 2

0

尝试使用Image(systemName: "arrow.right.circle").

这有点奇怪,但您实际上使用ImageView 在 iOS 上创建它们。

在 macOS 上,您可以将符号拖到 上的引号中Text(""),但这需要用户运行 Catalina(我不确定这是否是推荐的方式)。

于 2020-01-15T03:44:44.580 回答
0

您收到该错误是因为Text没有接受另一个视图的初始化程序..

如果您想在“有代码?”下放置图像 Text查看,然后您可以将您的更改VStack为以下内容:

VStack {
    Spacer()

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

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

否则,如果您想将图像放在“有代码?”的右侧。将上面的Text视图更改为.VStackHStack

于 2020-01-15T04:18:18.793 回答