Wednesday, July 1, 2026
HomeiOS Developmentios - SwiftUI - ScrollView and TextEditor Peak Not Working

ios – SwiftUI – ScrollView and TextEditor Peak Not Working

[ad_1]

I am posting this query once more, with a simplified view of my code and views. I will delete the previous one since I feel I did not clarify my situation correctly there (and it has no solutions but).

I am attempting to place a HStack with an preliminary peak on the backside of the display. With the highest portion being a scroll view. The HStack would possibly increase to a sure extent as extra textual content is typed into the Textual content Editor.

I’m able to obtain this, so long as there isn’t any Textual content Editor.

I need assistance with determining how to do that with Textual content Editor.

Please see beneath –

With only a textual content view

With a textual content editor as an alternative of textual content view

Here is the code for it –

struct ContentView: View {

@State var myText: String = "This Textual content Editor is screaming nn THIS IS SPARTA!!! nn at me and kicking me into the abyss of equally worded Stackoverflow questions."

var physique: some View{
    
    VStack(spacing:0){
        
        GeometryReader {geo in
            ScrollView(.vertical, showsIndicators: false){
                ForEach(1 ..< 200, id: .self){ num in
                    Textual content("(num)")
                        .body(width: geo.measurement.width)
                        .padding(5)
                        .background(.yellow)
                }
            }
            .background(.orange)
            .body(minWidth: geo.measurement.width, maxHeight: geo.measurement.peak * 0.96 , alignment: .high)
        }
        
        HStack(spacing: 0){
            Textual content("This HStack is meant to include a textual content editor that expands as wanted to a max peak however begins off at this peak.")
                .padding()
                .background(.teal)
            
            /*TextEditor(textual content: $myText)
             .multilineTextAlignment(.middle)
             .font(.title3)
             .padding()*/
        }
        .body(minHeight:50)
        .background(.teal)
    }
}}

Any assist in the fitting path is vastly appreciated!

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments