Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

iOS SwiftUI keyboard pushing makes texts folded

Can we simply push every content above the textfield to the top without folding text lines?

enter image description hereenter image description here

Here is my body code.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

var body: some View {
        ZStack(alignment: .top) {
            VStack(spacing: 24) {
                if DeviceUtil.getDeviceType() != .smallPhone {
                    Image(systemName: "sun.min.fill")
                        .resizable()
                        .scaledToFit()
                        .frame(width: 220, height: 46)
                    Image(systemName: "building.2")
                        .resizable()
                        .scaledToFit()
                        .frame(width: DeviceUtil.getDeviceType() == .iPad ? 350 : 200, height: DeviceUtil.getDeviceType() == .iPad ? 240 : 150)
                        .padding(.top, 24)
                } else {
                    Image("bLogo")
                        .resizable()
                        .scaledToFit()
                        .frame(width: 100, height: 34)
                    
                    Image("companyIntro")
                        .resizable()
                        .scaledToFit()
                        .frame(width: 100, height: 140)
                        .padding(.top, 12)
                }
                
                Text("One place\nfor all your work.")
                    .font(.titilliumWebRegular(size: DeviceUtil.getDeviceType() == .smallPhone ? 16 :  24))
                    .multilineTextAlignment(.center)
                
                Text("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi.")
                    .font(.titilliumWebRegular(size: 15))
                    .multilineTextAlignment(.center)
                
                HStack {
                    Rectangle()
                        .frame(height: 1)
                        .foregroundColor(.black)
                }
                .background(Color.gray.opacity(0.1))
                .padding(.horizontal, DeviceUtil.getDeviceType() == .normalPhone ? 64 : 34)
                mainContent
                Spacer()
            }
            .padding()
        }
        .background {
            Image("companyLaunch")
                .resizable()
                .scaledToFill()
                .ignoresSafeArea()
        }
    }

>Solution :

You can wrap your view in ScrollView for your content got push up without getting clipped:

ScrollView {
    ZStack(alignment: .top) {
        ...
    }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading