loady 1.0.7

loady 1.0.7

farshad jahanmanesh维护。



loady 1.0.7

  • farshad jahanmanesh

Version License Platform Swift

Loady

这是一个用于在UIButton中显示加载和指示器的库,具有完全可定制的样式。有6种不同的样式,您可以通过界面构建器或代码来设置颜色。

待办事项

  • 动画样式:类似于App Store的下载按钮
  • 动画样式:4阶段动画(normal,loading,success,error)
  • 动画样式:类似于Android
  • 动画样式:下载中
  • 可扩展以接受新的动画
  • 动画样式:类似于Telegram分享
  • Carthage支持

TOP_LINE

安装,cocoapods

loady最低目标要求为iOS 10.0

只需将这一行添加到您的Podfile中

  pod 'loady'

或者在手动安装情况下,只需将[源代码](https://github.com/farshadjahanmanesh/loady/tree/master/loady/LoadingButton)复制到您的项目中,查看示例项目以获取更多信息

配置

程序化设置

       // sets animation type
        self.loadyButton.setAnimation(LoadyAnimationType.backgroundHighlighter())
        
        // starts loading animation
        self.loadyButton?.startLoading()
        
        // some animations have filling background, or change the circle stroke, this sets the filling percent, number is something between 0 to 100
        loadyButton.update(percent: percent)

4 阶段动画

        // setup colors, titles and images
        self.fourPhases?.loadingColor = UIColor(red:0.38, green:0.66, blue:0.09, alpha:1.0)
        self.fourPhases.loadingColor = UIColor(red:0.38, green:0.66, blue:0.09, alpha:1.0)
			self.fourPhases.setPhases(phases: .init(
				normalPhase:
			(title: "Lock", image: UIImage(named: "unlocked"), background: UIColor(red:0.00, green:0.49, blue:0.90, alpha:1.0)), loadingPhase:
			(title: "Waiting...", image: nil, background: UIColor(red:0.17, green:0.24, blue:0.31, alpha:1.0)),
				successPhase:
			(title: "Activated", image: UIImage(named: "locked"), background: UIColor(red:0.15, green:0.68, blue:0.38, alpha:1.0)), errorPhase:
			(title: "Error", image: UIImage(named: "unlocked"), background: UIColor(red:0.64, green:0.00, blue:0.15, alpha:1.0))
				)
			)
        
        // then later in your code after user click on the button just call, this line take the button to loading phase, 
        self.fourPhasesLoadyButton?.startLoading()

        // in loading phase three different stage is available, you can cancel the loading by calling
        self.fourPhasesLoadyButton?.normalPhase()
        
        // you can take the button to success phase by calling
        self.fourPhasesLoadyButton?.successPhase()
        
        // you can take the button to error phase by calling
        self.fourPhasesLoadyButton?.errorPhase()
        
加载至正常 加载至成功 加载至错误

下载动画

// setup download button details
       self.downloadingLoadyButton.setAnimation(LoadyAnimationType.downloading(with: .init(
				downloadingLabel: (title: "Copying Data...", font: UIFont.boldSystemFont(ofSize: 18), textColor : UIColor(red:0, green:0.71, blue:0.8, alpha:1)),
				percentageLabel: (font: UIFont.boldSystemFont(ofSize: 14), textColor : UIColor(red:0, green:0.71, blue:0.8, alpha:1)),
				downloadedLabel: (title: "Completed.", font: UIFont.boldSystemFont(ofSize: 20), textColor : UIColor(red:0, green:0.71, blue:0.8, alpha:1))
				)
			))


在界面构建器中设置

设置类 更改属性

奖励 - NVActivityIndicatorView

如果你是 NVActivityIndicatorView 的粉丝,将其集成到 Loady 很简单,你可以用 NVActivityIndicatorView 替换我们的默认 iOS indicatorView <3,现在有一个新的属性接受 LoadyActivityIndicator 协议,只需像下面这样设置它

// first conform to the LoadyActivityIndicator protocol like this
extension NVActivityIndicatorView : LoadyActivityIndicator {
    
}

// then replace loady default activity indicator with yours
let nv = NVActivityIndicatorView(frame: .zero)
nv.type = .circleStrokeSpin
nv.color = .red
nv.padding = 12
self.loadyButton?.activiyIndicator = nv

| | |

故障排除

  1. 找不到 loady 的规范

如果在使用 Cocoapod 时遇到此类错误,请使用以下命令更新您的 pod

    > [!] Unable to find a specification for `loady`
    
    $ pod repo update
    $ pod install