答案 0 :(得分:0)
这是我的纹理视图:
struct RoughTextureView: View {
var body: some View {
Image("texture")
// Note: a resizable Image will fill its superview
.resizable(capInsets: EdgeInsets(), resizingMode: .tile)
}
}
...其中texture
是此50x50
图片:
这是使用方法:
struct ContentView: View {
var body: some View {
NavigationView {
ZStack {
RoughTextureView()
//...so it goes underneath the navigation bar
.edgesIgnoringSafeArea(.top)
ScrollView {
ForEach(0...100) { noteNumber in
HStack {
Text("Awesome note #\(noteNumber)")
.frame(height: 20)
.padding()
}
}
}
//...so it doesn't overlap with the navigation bar
.offset(x: 0, y: 20)
}
.navigationBarTitle(Text("My Notes").font(.largeTitle))
}
}
}
使用ZStack
将其放在所有视图的下方。
结果: