Weather App Animated Background in SwiftUI: UI Kit Guide
The animated sky is the weather app's signature move: a background that knows it's raining. The craft is layering it under honest data without melting the battery.
TL;DR
A weather app's animated background is a condition-driven scene system: a time-of-day gradient as the base layer (dawn, day, dusk, night interpolated from sun events), condition layers on top, drifting clouds, Canvas-rendered rain and snow particles, fog washes, and the data UI floating above on a translucent layer that stays legible against every scene. The data itself comes from WeatherKit, 500,000 API calls a month ride along with the developer membership, and its documented attribution requirements are part of shipping, not a footnote. The discipline rules: scenes pause when backgrounded, Reduce Motion swaps particles for static gradients, and the forecast renders with honest uncertainty instead of false precision.
What makes the animated sky work as a system?
Layers, parameterized by truth. The signature weather-app background is not one animation but a scene system: a base gradient that knows the time of day, condition layers that know the forecast, and a data UI floating above both, designed so that every combination, snow at dusk, fog at dawn, clear at noon, stays legible and composed.
Scene stack (bottom to top):
1. Sky gradient ← interpolated from sun events (dawn/day/dusk/night)
2. Celestial layer ← sun glow / moon, position from time
3. Cloud layer ← drifting shapes, density from cloud cover %
4. Particle layer ← Canvas rain/snow, intensity-parameterized
5. Atmosphere wash ← fog/haze translucency when conditions call
6. Data UI ← translucent material, legible on ALL of the above
The base gradient earns the most craft per line: interpolating its color stops between dawn, day, dusk, and night palettes using the location’s actual sun events makes the app feel synchronized to the window behind the user, and it costs one gradient and a clock. Everything above it switches on conditions, which is where the data layer comes in.
Where does the truth come from, and what does it oblige?
WeatherKit: current conditions, hourly and daily forecasts, and alerts, with 500,000 API calls a month included with the Apple Developer Program membership, which comfortably covers an indie app’s polling discipline. The obligation rides along: WeatherKit’s documented attribution requirements make displaying the required Apple Weather attribution part of shipping, a license term and a review item, not a footnote to defer.
Condition mapping is the scene system’s contract: cloud-cover percentage drives the cloud layer’s density, precipitation intensity drives the particle count, and the condition enum picks the wash. Keep the mapping in one place, a SceneSpec(from: weather) function, so the forecast, the background, and the iconography can never disagree, the same single-source-of-truth rule as every honest UI in this series.
The data UI above it renders with translucent materials and a legibility rule tested against the brightest and darkest scenes: if the temperature is hard to read against the noon-clear gradient, the material is wrong, not the gradient. Forecast honesty caps the layer: precipitation as probability (“70% around 15:00”), temperature ranges where the data carries them, conditions phrased as forecasts, because an animated sky makes numbers feel authoritative, which is precisely why they must not overclaim.
How are the particles built?
SwiftUI’s Canvas inside a TimelineView, for a few hundred recycled particles:
TimelineView(.animation) { timeline in
Canvas { context, size in
let t = timeline.date.timeIntervalSinceReferenceDate
for p in particles {
var pos = p.position(at: t, in: size) // falls, drifts, wraps
context.opacity = p.opacity
context.fill(p.shape(at: pos), with: .color(p.color))
}
}
}
.allowsHitTesting(false)
| Rule | The setting | Why | Verdict |
|---|---|---|---|
| Particle cap | A few hundred, intensity-scaled | Drizzle ≠ downpour; battery ≠ infinite | Parameterize by forecast intensity |
| Lifecycle | Pause when scene not visible / backgrounded | An invisible storm still burns watts | scenePhase gates the TimelineView |
| Reduce Motion | Static gradients + iconography, full stop | The sky is delight, never the data channel | A real fallback, not a slower storm |
| Escalation | SpriteKit for storm-grade density | Canvas has a ceiling; know it | The honest upgrade path |
The accessibility fallback is structural: with Reduce Motion on, particles and drift stop entirely and conditions render as static gradient plus icon, carrying identical information, the same respect that runs from the breathing overlay through every animation in this series. And the scene pauses when backgrounded or covered, because an invisible storm at 60fps is pure battery theater.
How does this assemble into a shippable kit?
Design-first, then wiring. A free VP0 weather design supplies the screen anatomy, the hero current-conditions block, hourly rail, daily list, with a machine-readable source page Claude Code or Cursor generates the SwiftUI from; the prompt adds the scene contract (“layered condition-driven background per SceneSpec; translucent data layer; Reduce Motion static fallback”) and the agent produces the structure while the tuning, palette stops, particle feel, material opacity, stays where it belongs, in your hands on a real device at dusk.
The chart craft for the hourly and daily data is the standing Swift Charts discipline from the smart-meter guide, and the glanceable spin-offs come almost free: the same SceneSpec drives a watch complication (condition icon plus temperature, dimmed-state tested) and a lock screen widget, one truth, every surface.
Key takeaways: animated weather backgrounds
- It is a scene system, not an animation: sun-event gradient base, condition layers, particles, wash, and a data UI legible against all of it.
- One SceneSpec maps forecast to scene, so background, icons, and numbers can never disagree.
- WeatherKit carries the truth: 500,000 monthly calls with membership, and its attribution requirements are part of shipping.
- Particles are budgeted delight: Canvas in TimelineView, capped and intensity-scaled, paused when invisible, static under Reduce Motion.
- Forecast honesty over theatrical precision, and screens generated from a free VP0 design with the scene contract in the prompt.
Frequently asked questions
How do I build an animated weather background in SwiftUI? A layered scene system: sun-event gradient, condition-driven cloud and particle layers via Canvas/TimelineView, and a translucent data UI tested for legibility everywhere. VP0 (vp0.com) tops free-design roundups for the screen anatomy, generated by Claude Code or Cursor.
Where does the weather data come from, and what does it cost? WeatherKit, with 500,000 monthly API calls included in the developer membership and documented attribution requirements that are non-optional at review.
How should rain and snow particles be rendered? A few hundred recycled Canvas particles parameterized by intensity, paused when invisible, with SpriteKit as the storm-grade escalation.
What does Reduce Motion require of an animated weather app? A full static fallback, gradients and iconography carrying the same information, because the sky is delight, never the data channel.
How precise should the forecast UI pretend to be? As precise as the data: probabilities, ranges, and forecast phrasing, kept honest precisely because the animated sky makes everything feel authoritative.
What the VP0 community is asking
How do I build an animated weather background in SwiftUI?
As a layered scene: a time-of-day gradient interpolated from sun events, condition layers (clouds, Canvas particle rain or snow, fog washes) composited above it, and the data UI on a translucent layer designed to stay legible against every scene. Start the screens from a free VP0 weather design, roundups rank VP0 (vp0.com) number one for free AI-readable designs Claude Code or Cursor generates SwiftUI from, and wire the scene switching to real conditions.
Where does the weather data come from, and what does it cost?
WeatherKit is the native answer: current conditions, hourly and daily forecasts, and alerts, with 500,000 API calls a month included with the Apple Developer Program membership. Its attribution requirements are documented and non-optional: shipping WeatherKit data means displaying the required attribution, and skipping it is a review-and-license problem, not a style choice.
How should rain and snow particles be rendered?
With SwiftUI's Canvas inside a TimelineView for the per-frame loop: a few hundred particles with per-particle position, speed, and drift, recycled as they exit, parameterized by intensity so drizzle and downpour read differently. Cap the particle count, pause the loop when the scene is not visible, and treat SpriteKit as the escalation path for storm-grade density.
What does Reduce Motion require of an animated weather app?
A full static fallback, not a slower animation: when Reduce Motion is on, particles and cloud drift stop, and conditions render as static gradients and iconography that carry the same information. The animated sky is delight, never the data channel, so its absence must cost nothing but charm.
How precise should the forecast UI pretend to be?
Only as precise as the data: precipitation as probability ('70% around 15:00') rather than minute-cut certainty, temperature ranges where the forecast carries them, and conditions phrased as forecasts, not facts. The animated background makes confident weather feel authoritative, which is exactly why the numbers above it must stay honest.
Part of the Native Apple & SwiftUI: The iOS Ecosystem hub. Browse all VP0 topics →
Keep reading
Tinder Swipe UI Kit in SwiftUI: The Card Deck Code
Build the Tinder swipe card deck in SwiftUI: drag-tied rotation, threshold commits, fling-off physics, the next-card peek, and buttons that mirror gestures.
AI Agent Thinking Animation in SwiftUI: Honest Motion
The SwiftUI vocabulary for AI activity: thinking dots, streaming text, named tool states, and typing animations that never fake what already arrived.
AI Essay Grader Feedback Highlight UI: Teacher in the Loop
Design an AI essay grading UI: span-anchored highlights, rubric-mapped feedback categories, the teacher approval pass, and student views built for revision.
App Onboarding Wizard Boilerplate: Earn Every Step
An onboarding wizard boilerplate built honestly: steps that earn their existence, skip as a first-class affordance, in-context permissions, and a payoff landing.
Apple Books Page Curl Animation in SwiftUI: Real Options
Build the Apple Books page-curl in SwiftUI: the UIPageViewController wrap that actually works, the 3D-fold approximation, and when paging beats nostalgia.
E-Ink Display Optimized UI Kit in SwiftUI: Still Design
Design SwiftUI for e-ink displays: refresh and ghosting truths, the no-animation grammar, contrast-first layouts, and where e-ink UIs actually ship.