ActivityIndicatorView
使用SwiftUI创建的多个预置加载指示器
我们是一家开发公司,致力于打造非凡的应用。
使用方法
创建指示器如下
ActivityIndicatorView(isVisible: $showLoadingIndicator, type: .default)
其中
showLoadingIndicator
- 您可以更改此布尔值以显示或隐藏指示器
type
- 来自 ActivityIndicatorView.IndicatorType
枚举的值
您可以使用标准的SwiftUI方法进行更改,如以下所示
ActivityIndicatorView(isVisible: $showLoadingIndicator, type: .default)
.frame(width: 50.0, height: 50.0)
.foregroundColor(.red)
或者指定其他指示器类型
ActivityIndicatorView(isVisible: $showLoadingIndicator, type: .growingArc(.red, lineWidth: 4))
.frame(width: 50.0, height: 50.0)
指标类型
每种指标类型都有一些默认参数,这些参数有合理的默认值。您可以按需更改它们,但建议不要设置得过高或过低。
default
- iOS UIActivityIndicatorView样式
.default(count: 8)
圆形
.arcs(count: 3, lineWidth: 2)
旋转点
.rotatingDots(count: 5)
闪烁点
.flickeringDots(count: 8)
缩放点
.scalingDots(count: 3, inset: 2)
透明点
.opacityDots(count: 3, inset: 4)
均衡器
.equalizer(count: 5)
growingArc
- 为渐增弧添加自定义颜色,默认值为Color.black
.growingArc(.red, lineWidth: 4))
growingCircle
无参数
gradient
- 有角度渐变边框填充的圆形,传递如下的颜色
.gradient([.white, .red], lineWidth: 4)
示例
尝试ActivityIndicatorView的示例
- 克隆仓库
git clone [email protected]:exyte/ActivityIndicatorView.git
- 打开终端并运行
cd <ActivityIndicatorViewRepo>/Example
- 运行
pod install
安装所有依赖 - 运行
xed .
用Xcode打开项目 - 试试吧!
安装
Swift包管理器
dependencies: [
.package(url: "https://github.com/exyte/ActivityIndicatorView.git")
]
CocoaPods
pod 'ActivityIndicatorView'
Carthage
github "Exyte/ActivityIndicatorView"
需求
- iOS 13+ / watchOS 6+ / tvOS 13+ / macOS 10.15+
- Xcode 11+
我们的其他开源 SwiftUI 库
PopupView - Toasts and popups library
Grid - The most powerful Grid container
ScalingHeaderScrollView - A scroll view with a sticky header which shrinks as you scroll
AnimatedTabBar - A tabbar with a number of preset animations
MediaPicker - Customizable media picker
ConcentricOnboarding - Animated onboarding flow
FloatingButton - Floating button menu
ProgressIndicatorView - A number of animated progress indicators
SVGView - SVG parser
LiquidSwipe - Liquid navigation animation