[英]Why am I getting the error "Instance method 'fill(_:style:)' requires that 'some View' conform to 'ShapeStyle'"?
[英]I keep getting this error Instance method 'background(_:ignoresSafeAreaEdges:)' requires that 'String' conform to 'ShapeStyle'
我對 swift 不是很有經驗,我正在嘗試制作一個應用程序。 我試過解決這個錯誤並搜索互聯網,但我找不到解決方案。 另請注意,我正在運行 Xcode 14 beta 3
這是錯誤,它發生在第 40 行(行開始“.padding(.vertical)”)
實例方法 'background(_:ignoresSafeAreaEdges:)' 要求 'String' 符合 'ShapeStyle'
這是代碼,
import SwiftUI
struct ContentView: View {
var body: some View {
ScrollView {
Text("text")
.font(.title2)
.fontWeight(.heavy)
.foregroundColor(Color.black)
.multilineTextAlignment(.center)
.padding([.top, .leading, .trailing], 15.0)
Image("Customise")
.resizable()
.scaledToFit()
Text("xkdlvlx")
.font(.title2)
.fontWeight(.heavy)
.foregroundColor(Color.black)
.multilineTextAlignment(.center)
.padding([.top, .leading, .trailing], 15.0)
Image("Customise")
.resizable()
.scaledToFit()
}
.safeAreaInset(edge: .bottom) {
Button("Hello"){
}
.frame(maxWidth: .infinity)
.padding(.vertical)
.background("StickyButtonBackground")
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
}
謝謝。
這個這個這里
.background("StickyButtonBackground")
我認為它可能是資產目錄中的顏色或圖像,例如
.background(Color("StickyButtonBackground"))
.background(Image("StickyButtonBackground"))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.