
Add button on safeArea side in SwiftUI touch is not working, this button should be tapable.
struct ContentView: View {
var body: some View {
VStack(spacing: 0) {
HStack(spacing: 0) {
Button(action: {
print("back menu")
}) {
Image(systemName: "globe")
.resizable()
.foregroundColor(.red)
}
.frame(width: 40, height: 40)
.padding(.leading, 20)
Spacer()
}
.padding(.top, 20)
Spacer()
}
.background(Color.gray)
.ignoresSafeArea()
}
}
I believe this is on purpose by Apple. Areas outside of the safe area are reserved for the system's user interface. It's recommended to keep most of your UI elements inside of the safe area region.