Hello, Im new to Xcode, ive been taking some classes and watching YouTube videos as well as using AI. Im having an issue I cannot find a video on, and AI just keeps screwing up my layout and sizing. Here is the issue, I have a Custom Made Image for my Sign In button, for my log in page on Xcode. The issue being that I can barely see the button and when I go to adjust the size the whole layout gets screwed up. My Logo Image (supposed to take up the top 50% of the screen) takes over the whole Botton of the screen and I loose my username and password Text threads and images. I guess my question is, is this an issue with the size of image ive uploaded or is this an issue with my code? I changed the size of the Image I created in Canva to 900pixles for the width and 300pixals for the height and that did absolutely nothing to my image in Xcode.
Below is the Button and Create Account section in my code that seems to be having issues. Ppppplease help me.
var body: some View { NavigationStack(path: $navigationPath) { ZStack { // Background image Image("Background1") .resizable() .scaledToFill() .ignoresSafeArea() .clipped() // Main content ScrollView { VStack(spacing: 20) { // Logo Image("DynastyStatDropLogo") .resizable() .scaledToFit() .padding(.top, -160) .padding(.bottom, -30) // Form elements // Username field ZStack { Image("UsernameBar") .resizable() .aspectRatio(contentMode: .fill) .padding() TextField("UserName:", text: $textInput) .padding(.horizontal, 75) .background(Color.clear) .foregroundColor(.red) .focused($focus, equals: .username) .submitLabel(.next) .onSubmit { focus = .password } } .frame(height: 50) .clipShape(RoundedRectangle(cornerRadius: 10)) .padding(.horizontal) // Password field and Forgot Password link VStack(spacing: 20) { ZStack { Image("PasswordBar") .resizable() .aspectRatio(contentMode: .fill) .padding() SecureField("Password:", text: $textInput2) .padding(.horizontal, 75) .background(Color.clear) .foregroundColor(.red) .focused($focus, equals: .password) .submitLabel(.go) .onSubmit { submitForm() } } .frame(height: 50) .clipShape(RoundedRectangle(cornerRadius: 10)) .padding(.horizontal) // Forgot Password link (right-aligned) HStack { Spacer() Text("Forgot Password?") .foregroundColor(.blue) .onTapGesture { navigationPath.append("passwordRecovery") } } .padding(.horizontal, 90) } Spacer(minLength: -110) // SignIn Button - Explicitly showing it HStack { Spacer() Button { submitForm() } label: { Image("signinButton") .resizable() .frame(width: 500, height: 400) } Spacer() } Spacer(minLength: -300) // Create Account (centered) HStack { Spacer() Text("Create Account") .foregroundColor(.blue) .onTapGesture { navigationPath.append("accountCreation") } Spacer() } .padding(.bottom, -10) } } } .onAppear { focus = .username } .navigationDestination(for: String.self) { destination in switch destination { case "dashboard": DSDDashboard() case "passwordRecovery": PasswordRecoveryView() case "accountCreation": AccountCreationView() default: EmptyView() } } .alert(isPresented: $showAlert) { Alert( title: Text("Missing Information"), message: Text("Enter UserName and Password to continue to DSD"), dismissButton: .default(Text("OK")) ) } } } // Function to handle form submission func submitForm() { focus = nil if textInput.isEmpty || textInput2.isEmpty { showAlert = true } else { print("Login with username: \(textInput), password: \(textInput2)") navigationPath.append("dashboard") } } // Enum to manage focus states enum FormFieldFocus: Hashable { case username, password }
}