Highlights the view with a shine moving over the view.
The angle is relative to the current layoutDirection, such that 0° represents sweeping towards the trailing edge and 90° represents sweeping towards the bottom edge.
Triggers a sound effect as feedback whenever a value changes.
This effect will not interrupt or duck any other audio that may currently playing. It may also not triggered based on the setting of the user’s silent switch or playback device.
To relay important information to the user, you should always accompany audio effects with visual cues.
interval: The duration between each change effect.
static func `repeat`(_ effect: AnyChangeEffect, every interval: Duration) -> AnyConditionalEffect
Parameters:
effect: The change effect to repeat.
interval: The number of seconds between each change effect.
static func `repeat`(_ effect: AnyChangeEffect, every interval: TimeInterval) -> AnyConditionalEffect
Particle Layer
A particle layer is a context in which particle effects draw their particles.
The particleLayer(name:) view modifier wraps the view in a particle layer with the given name.
Particle effects such as AnyChangeEffect.spray can render their particles on this position in the view tree to avoid being clipped by their immediate ancestor.
For example, certain List styles may clip their rows. Use particleLayer(_:) to render particles on top of the entire List or even its enclosing NavigationStack.
func particleLayer(name: AnyHashable) -> some View
Transitions
All transitions are namespaced under the movingParts static variable, e.g.
A transition that moves the view down with any overshoot resulting in an
elastic deformation of the view.
static var boing: AnyTransition
A transition that moves the view from the specified edge on insertion, and towards it on removal, with any overshoot resulting in an elastic deformation of the view.
A transitions that shows the view by combining a diagonal wipe with a
white streak.
static var glare: AnyTransition
A transitions that shows the view by combining a wipe with a colored
streak.
The angle is relative to the current layoutDirection, such that 0°
represents sweeping towards the trailing edge on insertion and 90°
represents sweeping towards the bottom edge.
In this example, the removal of the view is using a glare with an
exponential ease-in curve, combined with a anticipating scale animation,
making for a more dramatic exit.
A transition that moves the view from the specified edge of the on
insertion and towards it on removal.
static func move(edge: Edge) -> AnyTransition
A transition that moves the view at the specified angle.
The angle is relative to the current layoutDirection, such that 0° represents animating towards the trailing edge on insertion and 90° represents inserting towards the bottom edge.
In this example, the view insertion is animated by moving it towards the top trailing corner and the removal is animated by moving it towards the bottom edge.
A transition that moves the view in from its leading edge with any
overshoot resulting in an elastic deformation of the view.
static var skid: AnyTransition
A transition that moves the view in from the specified edge during
insertion and towards it during removal with any overshoot resulting
in an elastic deformation of the view.
Parameter direction: The direction of the transition.
A transition using a sweep at the specified angle.
The angle is relative to the current layoutDirection, such that 0°
represents sweeping towards the trailing edge on insertion and 90°
represents sweeping towards the bottom edge.
Parameters:
angle: The angle of the animation.
blurRadius: The radius of the blur applied to the mask.
:shopping_cart: Buy License |
Example App TestFlight |
Example App Repo
Pow
Delightful SwiftUI effects for your app.
Installation
To add a package dependency to your Xcode project, select File > Add Package and enter this repository’s URL (https://github.com/movingparts-io/Pow).
Overview
Pow features a selection of SwiftUI transitions as well as Change Effects that trigger every time a value is updated.
You can find previews of all effects on the Pow website. If you have an iOS Developer Environment, you can check out the Pow Example App.
Change Effects
Change Effects are effects that will trigger a visual or haptic every time a value changes.
Use the
changeEffect
modifier and pass in anAnyChangeEffect
as well as a value to watch for changes.You can choose from the following Change Effects: Spray, Glow, Haptic Feedback, Jump, Pulse, Rise, Shake, Shine, Spin, and Wiggle.
Spray
Preview
An effect that emits multiple particles in different shades and sizes moving up from the origin point.
origin
: The origin of the particles.layer
: TheParticleLayer
on which to render the effect, default islocal
.particles
: The particles to emit.Glow
Preview
An effect that highlights the view with a glow around it.
The glow appears for a second.
An effect that highlights the view with a glow around it.
The glow appears for a second.
color
: The color of the glow.radius
: The radius of the glow.Haptic Feedback
Triggers haptic feedback to communicate successes, failures, and warnings whenever a value changes.
notification
: The feedback type to trigger.Triggers haptic feedback to simulate physical impacts whenever a value changes.
impact
: The feedback style to trigger.Triggers haptic feedback to indicate a change in selection whenever a value changes.
Jump
Preview
Makes the view jump the given height and then bounces a few times before settling.
height
: The height of the jump.Pulse
Preview
An effect that adds one or more shapes that slowly grow and fade-out behind the view.
shape
: The shape to use for the effect.style
: The shape style to use for the effect. Defaults totint
.drawingMode
: The mode used to render the shape. Defaults tofill
.count
: The number of shapes to emit. Defaults to1
.layer
: TheParticleLayer
on which to render the effect. Defaults tolocal
.Rise
Preview
An effect that emits the provided particles from the origin point and slowly float up while moving side to side.
origin
: The origin of the particle.layer
: TheParticleLayer
on which to render the effect, default islocal
.particles
: The particles to emit.Shake
Preview
Shakes the view when a change happens.
An effect that shakes the view when a change happens.
rate
: The rate of the shake.Shine
Preview
Highlights the view with a shine moving over the view.
The shine moves from the top leading edge to bottom trailing edge.
Highlights the view with a shine moving over the view.
The shine moves from the top leading edge to bottom trailing edge.
Highlights the view with a shine moving over the view.
The angle is relative to the current
layoutDirection
, such that 0° represents sweeping towards the trailing edge and 90° represents sweeping towards the bottom edge.angle
: The angle of the animation.duration
: The duration of the animation.Sound Effect Feedback
Triggers a sound effect as feedback whenever a value changes.
This effect will not interrupt or duck any other audio that may currently playing. It may also not triggered based on the setting of the user’s silent switch or playback device.
To relay important information to the user, you should always accompany audio effects with visual cues.
soundEffect
: The sound effect to trigger.Spin
Preview
Spins the view around the given axis when a change happens.
Spins the view around the given axis when a change happens.
axis
: The x, y and z elements that specify the axis of rotation.anchor
: The location with a default of center that defines a point in 3D space about which the rotation is anchored.anchorZ
: The location with a default of 0 that defines a point in 3D space about which the rotation is anchored.perspective
: The relative vanishing point with a default of 1 / 6 for this rotation.rate
: The rate of the spin.Wiggle
Preview
An effect that wiggles the view when a change happens.
An effect that wiggles the view when a change happens.
rate
: The rate of the wiggle.Delay
Every change effect can be delayed to trigger the effect after some time.
delay
: The delay in seconds.Conditional Effects
Conditional Effects are effects that can be enabled or disabled through a boolean flag.
Use the
conditionalEffect
modifier and pass in anAnyConditionalEffect
as well as a condition to enable the effect.You can choose from the following Conditional Effects: Smoke, Push Down, and Glow.
Change Effects can be used with the Repeat modifier.
Smoke
Preview
An effect that emits smoke from the view.
An effect that emits smoke from the view.
layer
: TheParticleLayer
on which to render the effect, default islocal
.Push Down
An effect that pushes down the view while a condition is true.
Glow
Preview
An effect that highlights the view with a glow around it.
An effect that highlights the view with a glow around it.
color
: The color of the glow.radius
: The radius of the glow.Repeat
Repeats a change effect at the specified interval while a condition is true.
effect
: The change effect to repeat.interval
: The duration between each change effect.effect
: The change effect to repeat.interval
: The number of seconds between each change effect.Particle Layer
A particle layer is a context in which particle effects draw their particles.
The
particleLayer(name:)
view modifier wraps the view in a particle layer with the given name.Particle effects such as
AnyChangeEffect.spray
can render their particles on this position in the view tree to avoid being clipped by their immediate ancestor.For example, certain
List
styles may clip their rows. UseparticleLayer(_:)
to render particles on top of the entireList
or even its enclosingNavigationStack
.Transitions
All transitions are namespaced under the
movingParts
static variable, e.g.Anvil
Preview
A transition that drops the view down from the top with matching haptic feedback.
The transition is only performed on insertion and takes 1.4 seconds.
Blinds
Preview
A transition that reveals the view as if it was behind window blinds.
A transition that reveals the view as if it was behind window blinds.
Parameters:
slatWidth
: The width of each slat.style
: The style of blinds, either.venetian
or.vertical
.isStaggered
: Whether all slats opens at the same time or in sequence.Blur
Preview
A transition from blurry to sharp on insertion, and from sharp to blurry on removal.
A transition from blurry to sharp on insertion, and from sharp to blurry on removal.
radius
: The radial size of the blur at the end of the transition.Boing
Preview
A transition that moves the view down with any overshoot resulting in an elastic deformation of the view.
A transition that moves the view from the specified edge on insertion,
and towards it on removal, with any overshoot resulting in an elastic
deformation of the view.
Clock
Preview
A transition using a clockwise sweep around the centerpoint of the view.
A transition using a clockwise sweep around the centerpoint of the view.
blurRadius
: The radius of the blur applied to the mask.Flicker
Preview
A transition that toggles the visibility of the view multiple times before settling.
A transition that toggles the visibility of the view multiple times before settling.
count
: The number of times the visibility is toggled.Film Exposure
Preview
A transition from completely dark to fully visible on insertion, and from fully visible to completely dark on removal.
Flip
Preview
A transition that inserts by rotating the view towards the viewer, and removes by rotating the view away from the viewer.
Glare
Preview
A transitions that shows the view by combining a diagonal wipe with a white streak.
A transitions that shows the view by combining a wipe with a colored streak.
The angle is relative to the current
layoutDirection
, such that 0° represents sweeping towards the trailing edge on insertion and 90° represents sweeping towards the bottom edge.In this example, the removal of the view is using a glare with an exponential ease-in curve, combined with a anticipating scale animation, making for a more dramatic exit.
direction
: The angle of the wipe.color
: The color of the glare effect.Iris
Preview
A transition that takes the shape of a growing circle when inserting, and a shrinking circle when removing.
origin
: The center point of the circle as it grows or shrinks.blurRadius
: The radius of the blur applied to the mask.Move
Preview
A transition that moves the view from the specified edge of the on insertion and towards it on removal.
A transition that moves the view at the specified angle.
The angle is relative to the current
layoutDirection
, such that 0° represents animating towards the trailing edge on insertion and 90° represents inserting towards the bottom edge.In this example, the view insertion is animated by moving it towards the top trailing corner and the removal is animated by moving it towards the bottom edge.
angle
: The direction of the animation.Pop
Preview
A transition that shows a view with a ripple effect and a flurry of tint-colored particles.
The transition is only performed on insertion and takes 1.2 seconds.
A transition that shows a view with a ripple effect and a flurry of colored particles.
In this example, the star uses the pop effect only when transitioning from
starred == false
tostarred == true
:The transition is only performed on insertion.
style
: The style to use for the effect.Poof
Preview
A transition that removes the view in a dissolving cartoon style cloud.
The transition is only performed on removal and takes 0.4 seconds.
Rotate3D
A transition that inserts by rotating from the specified rotation, and removes by rotating to the specified rotation in three dimensions.
In this example, the view is rotated 90˚ about the y axis around its bottom edge as if it was rising from lying on its back face:
angle
: The angle from which to rotate the view.axis
: The x, y and z elements that specify the axis of rotation.anchor
: The location with a default of center that defines a pointanchorZ
: The location with a default of 0 that defines a point in 3Dperspective
: The relative vanishing point with a default of 1 forSnapshot
Preview
A transition from completely bright to fully visible on insertion, and from fully visible to completely bright on removal.
Skid
Preview
A transition that moves the view in from its leading edge with any overshoot resulting in an elastic deformation of the view.
A transition that moves the view in from the specified edge during insertion and towards it during removal with any overshoot resulting in an elastic deformation of the view.
direction
: The direction of the transition.Swoosh
Preview
A three-dimensional transition from the back of the towards the front during insertion and from the front towards the back during removal.
Vanish
Preview
A transition that dissolves the view into many small particles.
The transition is only performed on removal.
A transition that dissolves the view into many small particles.
The transition is only performed on removal.
style
: The style to use for the particles.A transition that dissolves the view into many small particles following a given shape.
The transition is only performed on removal.
style
: The style to use for the particles.mask
: The mask that determines where particles should be placed.eoFill
: A Boolean that indicates whether the shape is interpreted with the even-odd winding number rule.Wipe
Preview
A transition using a sweep from the specified edge on insertion, and towards it on removal.
edge
: The edge at which the sweep starts or ends.blurRadius
: The radius of the blur applied to the mask.A transition using a sweep at the specified angle.
The angle is relative to the current
layoutDirection
, such that 0° represents sweeping towards the trailing edge on insertion and 90° represents sweeping towards the bottom edge.angle
: The angle of the animation.blurRadius
: The radius of the blur applied to the mask.