当前位置:网站首页>Swiftui retrieves the missing list view animation

Swiftui retrieves the missing list view animation

2022-06-26 15:54:00 Giant panda Hou Pei

 Insert picture description here



Problem phenomenon

Many beginners SwiftUI My friends are fitting in List There is often a small annoying problem when viewing :List Content changes but no animation effect .

 Insert picture description here

As shown in the figure above : User is changing List The item sorting method will change the display order of the list items , This change does not animate in the list .

What's the reason for this ?

The answer is simpler than you think !

So,Let‘s dive in!



Problem analysis

1. SwiftUI List animation principle

SwiftUI The animation in the view is driven by state changes ,List No exception .

struct ContentView: View { 
    
    @State 
原网站

版权声明
本文为[Giant panda Hou Pei]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206261322019649.html