Animacje niejawne
Animuj zmiany stanu za pomocą modyfikatora animation
Animacje niejawne to bezpłatna lekcja SwiftUI Academy na CoddyKit. To lekcja 1 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej SwiftUI Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs SwiftUI Academy zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
Motion Makes It Feel Alive
A change that snaps into place feels jarring. With animation, SwiftUI smoothly tweens between the old and new states for you. ✨
What Implicit Means
An implicit animation watches a value and animates any view change caused by it, without you describing each frame.
The .animation Modifier
You attach .animation to a view and tie it to a value. When that value changes, SwiftUI animates the affected properties.
Circle()
.scaleEffect(big ? 2 : 1)
.animation(.default, value: big)Always Pass a Value
Modern .animation(_:value:) needs the value to observe. SwiftUI only animates when that exact value changes, keeping motion predictable.
What Gets Animated
SwiftUI animates the animatable properties between states: position, size, opacity, rotation, and color all tween smoothly.
Pick a Curve
The first argument is the animation curve. Common choices are .default, .easeInOut, .linear, and .spring for different feels.
.animation(.easeInOut, value: isOn)Control the Duration
Add a duration to set how long the motion lasts. A short 0.2s feels snappy; a longer 1s feels relaxed.
.animation(.easeInOut(duration: 0.4), value: isOn)Animate Opacity
Fading is a classic implicit animation. Change opacity with a bound value and SwiftUI cross-fades the view in or out.
Text("Hi")
.opacity(show ? 1 : 0)
.animation(.easeIn, value: show)Animate Rotation
Tie rotationEffect to a value and the view spins smoothly when it flips, perfect for chevrons and loading marks.
.rotationEffect(.degrees(open ? 90 : 0))
.animation(.default, value: open)Scope It to One Value
Because you name the value, only changes to that value animate. Other view updates stay instant and unaffected.
Turn Animation Off
Pass nil as the animation to disable motion for that value. Handy when a change should jump instantly instead.
.animation(nil, value: count)Quick Check
How does an implicit animation know when to run?
Recap: Implicit Animations
You learned that .animation(_:value:) smoothly tweens view changes tied to a value. Pick a curve, set duration, and SwiftUI handles the rest. 🎉
Często zadawane pytania
Czy lekcja „Animacje niejawne” jest bezpłatna?
Tak — pełny tekst „Animacje niejawne” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu SwiftUI Academy, przejdź na CoddyKit PRO. Kurs SwiftUI Academy zawiera 4 lekcji w sumie.
Co nauczysz się w „Animacje niejawne”?
Animuj zmiany stanu za pomocą modyfikatora animation Ćwiczysz SwiftUI Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć SwiftUI Academy?
Nie wymagamy żadnego doświadczenia. SwiftUI Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 1 z 4.
Ile czasu zajmuje lekcja „Animacje niejawne”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji SwiftUI Academy?
Tak. Każda lekcja SwiftUI Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Animacje niejawne
- Jawne animacje z withAnimation
- Przejścia podczas wstawiania i usuwania
- Sprężyny i niestandardowe krzywe czasu