Close Menu
  • Home
  • AI
  • Big Data
  • Cloud Computing
  • iOS Development
  • IoT
  • IT/ Cybersecurity
  • Tech
    • Nanotechnology
    • Green Technology
    • Apple
    • Software Development
    • Software Engineering

Subscribe to Updates

Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

    What's Hot

    ios – Verbose Swift code, looking for advice on simplifying and improving

    February 16, 2026

    How Cisco Transforms AI Data Centers

    February 16, 2026

    AT&T reveals its iPhone 16 deals — get up to $1,000 off with an eligible trade-in

    February 16, 2026
    Facebook X (Twitter) Instagram
    Facebook X (Twitter) Instagram
    Big Tee Tech Hub
    • Home
    • AI
    • Big Data
    • Cloud Computing
    • iOS Development
    • IoT
    • IT/ Cybersecurity
    • Tech
      • Nanotechnology
      • Green Technology
      • Apple
      • Software Development
      • Software Engineering
    Big Tee Tech Hub
    Home»iOS Development»ios – SwiftUI List row expansion doesn’t animate smoothly; items below jump abruptly
    iOS Development

    ios – SwiftUI List row expansion doesn’t animate smoothly; items below jump abruptly

    big tee tech hubBy big tee tech hubJanuary 27, 2026022 Mins Read
    Share Facebook Twitter Pinterest Copy Link LinkedIn Tumblr Email Telegram WhatsApp
    Follow Us
    Google News Flipboard
    ios – SwiftUI List row expansion doesn’t animate smoothly; items below jump abruptly
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    It is generally difficult to animate a change in height for a List row smoothly. However, a possible workaround is to use a DisclosureGroup.

    When a DisclosureGroup with native styling is used in a List, it navigates quite smoothly. The way it works is actually to add a new row to the list when expanded. To use your own styling, a custom DisclosureGroupStyle can be used. By using the same technique of adding an extra row for the expanded content, the animation works quite smoothly.

    Some notes:

    • Tracking the expanded state can be handled by the DisclosureGroup.
    • The function makeBody of the custom style should return two rows when the content is expanded. This is done by not using a VStack as outer container for the content.
    • The vertical spacing for the expanded content can be reduced by applying custom .listRowInsets.
    • The list row separator above the expanded note can be hidden.
    • The alignment of the separator below the expanded note can be controlled using an .alignmentGuide.

    Here is how your example can be adapted to work this way:

    struct MyDisclosureGroupStyle: DisclosureGroupStyle {
        func makeBody(configuration: Configuration) -> some View {
            HStack(spacing: 12) {
                configuration.label
                Spacer()
                Button {
                    withAnimation {
                        configuration.isExpanded.toggle()
                    }
                } label: {
                    Image(systemName: "note.text")
                        .imageScale(.medium)
                }
                .buttonStyle(.plain)
            }
            .padding(.vertical, 8)
    
            if configuration.isExpanded {
                configuration.content
                    .listRowInsets(.init(top: 0, leading: 16, bottom: 10, trailing: 16))
                    .padding(.bottom, 8)
                    .listRowSeparator(.hidden, edges: .top)
                    .alignmentGuide(.listRowSeparatorLeading) { dim in
                        0
                    }
            }
        }
    }
    
    struct ContentView: View {
        private let items: [HistoryItem] = [
            HistoryItem(id: UUID(), title: "Client A - Morning shift", note: "Short note for entry 1."),
            HistoryItem(id: UUID(), title: "Client B - Field visit", note: "Longer note for entry 2 so the row expands more than the others."),
            HistoryItem(id: UUID(), title: "Client C - Training", note: nil),
            HistoryItem(id: UUID(), title: "Client D - Support", note: "Another note for entry 4."),
            HistoryItem(id: UUID(), title: "Client E - Wrap up", note: "Final note for entry 5.")
        ]
    
        var body: some View {
            NavigationStack {
                List {
                    ForEach(items) { item in
                        if let note = item.note {
                            DisclosureGroup {
                                Text(note)
                                    .font(.subheadline)
                                    .foregroundStyle(.secondary)
                                    .padding(10)
                                    .background(.background.secondary, in: .rect(cornerRadius: 8))
                            } label: {
                                Text(item.title)
                                    .font(.headline)
                            }
                            .disclosureGroupStyle(MyDisclosureGroupStyle())
                        } else {
                            Text(item.title)
                                .font(.headline)
                                .padding(.vertical, 8)
                        }
                    }
                }
                .listStyle(.plain)
                .navigationTitle("History")
            }
        }
    }
    

    Animation



    Source link

    abruptly animate doesnt Expansion iOS Items Jump list Row smoothly SwiftUI
    Follow on Google News Follow on Flipboard
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    tonirufai
    big tee tech hub
    • Website

    Related Posts

    ios – Verbose Swift code, looking for advice on simplifying and improving

    February 16, 2026

    Fatal ‘Index out of range’ error when using macOS simulator in Xcode but not when using iOS simulator

    February 15, 2026

    ios – How to persist credit balance in a credit-based AI app when using anonymous sign-in?

    February 14, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    ios – Verbose Swift code, looking for advice on simplifying and improving

    February 16, 2026

    How Cisco Transforms AI Data Centers

    February 16, 2026

    AT&T reveals its iPhone 16 deals — get up to $1,000 off with an eligible trade-in

    February 16, 2026

    TypeScript 6.0 beta lays the foundation for shifting the codebase from JavaScript to Go

    February 15, 2026
    About Us
    About Us

    Welcome To big tee tech hub. Big tee tech hub is a Professional seo tools Platform. Here we will provide you only interesting content, which you will like very much. We’re dedicated to providing you the best of seo tools, with a focus on dependability and tools. We’re working to turn our passion for seo tools into a booming online website. We hope you enjoy our seo tools as much as we enjoy offering them to you.

    Don't Miss!

    ios – Verbose Swift code, looking for advice on simplifying and improving

    February 16, 2026

    How Cisco Transforms AI Data Centers

    February 16, 2026

    Subscribe to Updates

    Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

      • About Us
      • Contact Us
      • Disclaimer
      • Privacy Policy
      • Terms and Conditions
      © 2026 bigteetechhub.All Right Reserved

      Type above and press Enter to search. Press Esc to cancel.