MHLoadingButton 0.1.3

MHLoadingButton 0.1.3

Michael Ho 维护。



加载按钮

由 Swift 编写的一系列加载按钮及其样式。

Generic badge Generic badge Generic badge Generic badge

你可以阅读以下 Medium 文章,详细了解创建加载按钮的过程。

浅色模式 深色模式
Overview Overview Dark

主要特性

  • 示例提供 9 种不同的加载指示器选项。
  • IndicatorProtocol 清楚地定义了函数和属性,你可以参考它并自定义自己的。
  • LoadingButton 类是 公开的,从它可以轻松继承并创建自己的。

要求

  • Swift 5.0
  • iOS 11.0+

安装

CocoaPods

LoadingButtons 项目可通过 CocoaPods 获得。要安装,请简单地将以下行添加到 Podfile 中

$ pod 'MHLoadingButton'

Swift Package Manager

Package.swift 中将 LoadingButtons 作为依赖项添加

import PackageDescription

let package = Package(
    name: "YourPackage",
    dependencies: [
        .Package(url: "https://github.com/twho/loading-buttons-ios.git", majorVersion: 0),
    ]
)

如果您 neither CocoaPods 还是 Swift Package Manager,可以下载整个项目然后将所有源文件导入到您的项目中使用。

使用方法

声明

// The frame is default to zero. You need to use AutoLayout to resize it. 
// Otherwise, you can specify the frame in initializer.
if #available(iOS 13.0, *) {
    // This is the new initializer for iOS 13 dark/light mode. 
    // The syste colors will be used.
    btnLoading = LoadingButton(text: "Button", buttonStyle: .outline) // Outlined button
    btnLoading = LoadingButton(text: "Button", buttonStyle: .fill)    // Filled button
} else {
    // Custom color initializer
    btnLoading = LoadingButton(text: "Button", textColor: .black, bgColor: .white)
}

系统默认

btnLoading.indicator = UIActivityIndicatorView()
浅色模式 深色模式
System Default System Default Dark

材料设计

btnLoading.indicator = MaterialLoadingIndicator(color: .gray)
浅色模式 深色模式
Material Design Material Design Dark

球形脉冲

btnLoading.indicator = BallPulseSyncIndicator(color: .gray)
浅色模式 深色模式
Ball Pulse Ball Pulse Dark

球脉冲同步

btnLoading.indicator = BallSpinFadeIndicator(color: .gray)
浅色模式 深色模式
Ball Pulse Sync Ball Pulse Sync Dark

球旋转

btnLoading.indicator = LineScalePulseIndicator(color: .gray)
浅色模式 深色模式
Ball Spin Ball Spin Dark

线比例

btnLoading.indicator = LineScaleIndicator(color: .gray)
浅色模式 深色模式
Line Scale Line Scale Dark

线比例脉冲

btnLoading.indicator = BallPulseIndicator(color: .gray)
浅色模式 深色模式
Line Scale Pulse Line Scale Pulse Dark

球打击

btnLoading.indicator = BallBeatIndicator(color: .gray)
浅色模式 深色模式
Ball Beat Ball Beat Dark

线旋转

btnLoading.indicator = LineSpinFadeLoader(color: .gray)
浅色模式 深色模式
Line Spin Line Spin Dark

致谢