You can take reference from this code.
import SwiftUI
struct ContentView: View {
var body: some View {
ZStack{
Button (action: {})
{
VStack{
ZStack{
VStack{
Image("image")
.resizable()
.overlay {
Button {
// any action
} label: {
Text("Let's Get acquainted")
.font(.system(size: 50))
.foregroundColor(.white)
.bold()
.position(x: 150, y: 100)
}
}
}
}
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
You need to use either a ZStack
or .overlay
:
ZStack
:ZStack(alignment: .bottomTrailing) {
//your content
//your image
}
.overlay
://your content
.overlay(alignment: .bottomTrailing) {
//your Button
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.