Im newer to Swift and Swift UI but im building a simple ai powered chatbox but the button that I have in the UI, when I try to move it back into position using the X,Y offset modifiers, the button gets partially hidden in the body of the UI as can be seen in the bottom right of the picture provided.
func makeTextFieldAndButton() -> some View { HStack { Spacer() TextField("Ask Mac GPT...", text: $text) .font(Font.custom("Futura", size: 17.4)) .fontWeight(.bold) .padding(.horizontal, 25) .padding(.vertical, 15) .background(Color.white) .cornerRadius(29) .overlay( RoundedRectangle(cornerRadius: 27.9).stroke(Color.gray, lineWidth: 1.2) ) .offset(y: -120)
Button(action: {
let process = Process()
process.executableURL = URL(fileURLWithPath: "/usr/bin/swift")
process.arguments = ["/Users/alexhaidar/Documents/Developer/Mac GPT/serverSide.swift", filePath]
try? process.run()
}) {
ZStack{
Spacer()
Image(systemName: "arrow.up.circle.fill")
.foregroundColor(Color.blue)
.font(Font.system(size: 40))
.buttonStyle(PlainButtonStyle())
.padding(.top)
.offset(y: max(-12, -120 + (text.isEmpty ? -10 : 0)))
.offset(x: max(-21, text.isEmpty ? -21 : 0))
}
}
.overlay(
RoundedRectangle(cornerRadius: 27.9)
.stroke(Color.clear, lineWidth: 1.2)
)
.background(Color.clear)
.offset(x: 21)
}
}
}