Swiftpack.co - markiv/SwiftUI-Shimmer as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by markiv.
markiv/SwiftUI-Shimmer 1.4.2
Shimmer is a super-light modifier that adds a shimmering effect to any SwiftUI View, for example, to show that an operation is in progress. It works well on light and dark modes, and across iOS, macOS, tvOS, watchOS and visionOS.
⭐️ 903
🕓 12 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/markiv/SwiftUI-Shimmer.git", from: "1.4.2")

SwiftUI-Shimmer ✨

Shimmer is a super-light modifier that adds a "shimmering" effect to any SwiftUI View, for example, to show that an operation is in progress. It works well on light and dark modes, left-to-right and right-to-left layout directions, and across all Apple platforms: iOS, macOS, tvOS, watchOS and even visionOS! 📱💻🖥️📺⌚️🥽✨

visionOS watchOS

Usage

import SwiftUI
import Shimmer
⋮
⋮
Text("SwiftUI Shimmer").modifier(Shimmer())

or more conveniently

Text("SwiftUI Shimmer").shimmering()

Light Mode Dark Mode

Optional Parameters ⚙️

  • active: Convenience parameter to conditionally enable the effect. Defaults to true.
  • animation: A custom animation. Defaults to Shimmer.defaultAnimation.
  • gradient: A custom gradient. Defaults to Shimmer.defaultGradient.
  • bandSize: The size of the animated mask's "band". Defaults to 0.2 unit points, which corresponds to 20% of the extent of the gradient.

Backward Compatible Parameters

  • active: Convenience parameter to conditionally enable the effect. Defaults to true.
  • duration: The duration of a shimmer cycle in seconds. Default: 1.5.
  • bounce: Whether to bounce (reverse) the animation back and forth. Defaults to false.
  • delay: A delay in seconds. Defaults to 0.

Bounce 3

Custom Animations

You can supply any custom animation:

Text("Loading...")
    .shimmering(
        active: isAnimating,
        animation: .easeInOut(duration: 2).repeatCount(5, autoreverses: false).delay(1)
    )

Animated Skeletons ☠️

Of course, you can combine .shimmering(...) with the .redacted(...) modifier to create interesting animated skeleton views.

Loading

Text("Some text")
    .redacted(reason: .placeholder)
    .shimmering()

Right-To-Left (RTL) Support

The mask and animation now adjusts automatically to the environment's layoutDirection in order to better support different languages and locales.

Installation

Swift Package Manager

Use the package URL or search for the SwiftUI-Shimmer package: https://github.com/markiv/SwiftUI-Shimmer.

For how-to integrate package dependencies refer to Adding Package Dependencies to Your App documentation.

Cocoapods

Add this to your Podfile:

pod 'SwiftUI-Shimmer', :git => 'https://github.com/markiv/SwiftUI-Shimmer.git'

What About UIKit?

For an older, UIKit-based shimmer effect, see UIView-Shimmer.

GitHub

link
Stars: 903
Last commit: 12 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Animate gradient start and end points instead of stop locations
35 weeks ago

The shimmer animation no longer worked on the iOS 17 betas. This release uses a different approach, by animating the gradient's start and end points (instead of stop locations as before). Additionally, the gradient and "band size" are now customisable.

Full Changelog: https://github.com/markiv/SwiftUI-Shimmer/compare/1.3.0...1.4.0

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics