Sunday, July 27, 2025
HomeiOS Developmentios - make prime a part of record background keep fastened?

ios – make prime a part of record background keep fastened?


How do I make the highest a part of the record background to remain fastened?

For instance, right here, the higher a part of the record background (the sunshine gray) shouldn’t slide up. In different phrases, the record background ought to solely be allowed to maneuver in direction of the underside of the display screen.

enter image description here

import SwiftUI
import Basis

struct Attendance: Identifiable {
    let id = UUID()
    let title: String
}

struct AttendanceRow: View {
    var attendance: Attendance
    
    var physique: some View {
        HStack {
            Textual content(attendance.title)
        }
        .padding(.vertical, 20)
    }
}

struct ContentView: View {
    let attendances = [
        Attendance(name: "John"),
        Attendance(name: "Michael"),
        Attendance(name: "Steve"),
        Attendance(name: "Donald"),
        Attendance(name: "Johathan"),
        Attendance(name: "William"),
        Attendance(name: "Dave"),
        Attendance(name: "Richard"),
        Attendance(name: "Boris"),
        Attendance(name: "Catherine"),
        Attendance(name: "Susan")
    ]
    
    var physique: some View {
        NavigationView {
            VStack {
                Record {
                    ForEach(attendances) { attendance in
                        AttendanceRow(attendance: attendance)
                    }
                }
            }
        }
    }
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments