SwiftfulThinking/SwiftfulLoadingIndicators
关于
一组轻量级 SwiftUI 加载动画。
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- +1
- 15天
- +2
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文SwiftfulLoadingIndicators
A collection of lightweight loading animations that can be applied to any SwiftUI view with 1 line of code. All animations are built using the SwiftUI framework (and in a few cases, the Combine framework).
:thumbsup: 20+ animations!
:art: Works with any Color
:toolbox: Customize speed & size
:white_check_mark: No keyframe animations or DispatchQueue calls that could negatively affect the UI
:white_check_mark: Source files have no depencendies and can be extracted without issue

Installation
Swift Package Manager
The Swift Package Manager is a tool for managing the distribution of Swift code. To use SwiftfulLoadingIndicators with Swift Package Manager in an Xcode project:
- File -> Swift Packages -> Add Package Dependency ->
- Add URL for this repository: https://github.com/SwiftfulThinking/SwiftfulLoadingIndicators.git
Usage
Firstly, import the package to your file.
import SwiftfulLoadingIndicators
Then add a LoadingIndicator to your SwiftUI view.
LoadingIndicator()
The indicators are customizable in terms of animation, color, size, and speed. All parameters are optional and will init with default values if not included. Example implementations:
// DEFAULT PARAMETERS:
// Animation == .threeBalls
// Color == .primary
// Size == .medium
// Speed == .normal
LoadingIndicator()
LoadingIndicator(animation: .fiveLines)
LoadingIndicator(animation: .fiveLines, color: .red)
LoadingIndicator(animation: .fiveLines, color: .red, size: .large)
LoadingIndicator(animation: .fiveLines, color: .red, size: .large, speed: .fast)
LoadingIndicator(color: .red)
LoadingIndicator(size: .large)
LoadingIndicator(speed: .slow)
The indicators will animate as soon as they appear on the screen, similar to the native ProgressView(). Recommended approach is to add the indicator to the View only when it is required:
if isLoading {
LoadingIndicator()
}
To quickly see all animation options, simply add a LoadingShowcaseView.
LoadingShowcaseView()
To quickly see all size and speed options for a single animation, simply add a LoadingPreviewView.
LoadingPreviewView(animation: .threeBalls)
Additional Configuration & Notes
All loading indicators are built for SwiftUI. The majority of animations are triggered by toggling a very simple @State variable when they appear. A few of the more complex animations use a Publisher through the Combine framework.
The animations are meant to be highly customizable and each animation file does not have any external dependencies. If you would prefer to (1) customize one of the animations or (2) only include one of the animations in your project, you can simple copy + paste the source file directly.
- path: SwiftfulLoadingIndicators/Sources/SwiftfulLoadingIndicators/Animations/
Supported Platforms:
- .macOS(.v11)
- .iOS(.v13)
- .tvOS(.v14)
- .watchOS(.v7)
探索相关项目
加载中…