如何正确创建顺丰符号?
How to create an SF Symbol Properly?
我试图将 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()
}
}
尝试使用 Image(systemName: "arrow.right.circle")
。
这有点奇怪,但您实际上使用 Image
视图在 iOS 上创建它们。
在 macOS 上,您可以将符号拖到 Text("")
上的引号中,但这要求用户是 运行 Catalina(我不确定这是否是推荐的方式)。
您收到该错误是因为 Text
没有接受另一个视图的初始化器..
如果要在 'Have a Code?' Text
视图下放置图像,则可以将 VStack
更改为以下内容:
VStack {
Spacer()
Text("Have a code?")
.padding()
.foregroundColor(.blue)
.font(.callout)
Image(systemName: "arrow.right.circle")
}
否则,如果您想将图像放在 'Have a Code?' Text
视图的右侧,请将上面的 VStack
更改为 HStack
。
我试图将 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()
}
}
尝试使用 Image(systemName: "arrow.right.circle")
。
这有点奇怪,但您实际上使用 Image
视图在 iOS 上创建它们。
在 macOS 上,您可以将符号拖到 Text("")
上的引号中,但这要求用户是 运行 Catalina(我不确定这是否是推荐的方式)。
您收到该错误是因为 Text
没有接受另一个视图的初始化器..
如果要在 'Have a Code?' Text
视图下放置图像,则可以将 VStack
更改为以下内容:
VStack {
Spacer()
Text("Have a code?")
.padding()
.foregroundColor(.blue)
.font(.callout)
Image(systemName: "arrow.right.circle")
}
否则,如果您想将图像放在 'Have a Code?' Text
视图的右侧,请将上面的 VStack
更改为 HStack
。