Home > AI > IOS > SwiftUI >

(Exampe) stretchy poster

import SwiftUI

struct ContentView: View {
    
    var body: some View {
        ScrollView {
            GeometryReader { geo in
                Image("poster")
                    .resizable()
    
                // fixing the view to the top will give strechy effect...
                // increasing height by drag amount....
                    .offset(y: geo.frame(in: .global).minY > 0 ? -geo.frame(in: .global).minY : 0)
                    .frame(height: geo.frame(in: .global).minY > 0 ? UIScreen.main.bounds.height / 2.2 + geo.frame(in: .global).minY  : UIScreen.main.bounds.height / 2.2)
            }
        }
    }
}

Leave a Reply