Skip to content

Repository files navigation

Gradient Circular Progress

Customizable progress indicator library in Swift

Requirements

  • Swift 4.2
  • iOS 8.0 or later

Screen Shots

  • All preset styles

  • Example Use AddSubView

Installation

###Carthage

  • Cartfile
github "keygx/GradientCircularProgress"

or

github "keygx/GradientCircularProgress" "branch-name"

or

github "keygx/GradientCircularProgress" "tag"
  • install
$ carthage update

To integrate "GradientCircularProgress.framework" into your Xcode project

###CocoaPods

  • PodFile [Sample/PodFile]
platform :ios, '8.0'
target '<Your Target Name>' do
use_frameworks!
pod 'GradientCircularProgress', :git => 'https://github.com/keygx/GradientCircularProgress'
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.1'
end
end
end
end

or

platform :ios, '8.0'
target '<Your Target Name>' do
use_frameworks!
pod 'GradientCircularProgress', :git => 'https://github.com/keygx/GradientCircularProgress', :branch => 'branch-name'
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.1'
end
end
end
end

or

platform :ios, '8.0'
target '<Your Target Name>' do
use_frameworks!
pod 'GradientCircularProgress', :git => 'https://github.com/keygx/GradientCircularProgress', :tag => 'tag'
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.1'
end
end
end
end
  • install
$ pod install

Style Settings

Please make your original styles

  • Define custom style structs that implements the StyleProperty Protocol

MyStyle.swift

import GradientCircularProgress
publicstructMyStyle:StyleProperty{
/*** style properties **********************************************************************************/
// Progress Size
publicvarprogressSize:CGFloat=200
// Gradient Circular
publicvararcLineWidth:CGFloat=18.0publicvarstartArcColor:UIColor=UIColor.clear()publicvarendArcColor:UIColor=UIColor.orange()
// Base Circular
publicvarbaseLineWidth:CGFloat?=19.0publicvarbaseArcColor:UIColor?=UIColor.darkGray()
// Ratio
publicvarratioLabelFont:UIFont?=UIFont(name:"Verdana-Bold", size:16.0)publicvarratioLabelFontColor:UIColor?=UIColor.white()
// Message
publicvarmessageLabelFont:UIFont?=UIFont.systemFont(ofSize:16.0)publicvarmessageLabelFontColor:UIColor?=UIColor.white()
// Background
publicvarbackgroundStyle:BackgroundStyles=.dark
// Dismiss
publicvardismissTimeInterval:Double?=0.0 // 'nil' for default setting.
/*** style properties **********************************************************************************/
publicinit(){}}

Usage

import GradientCircularProgress

Basic

UIWindow

letprogress=GradientCircularProgress()
progress.show(message:"Loading...",MyStyle())
progress.dismiss()

addSubView

letprogress=GradientCircularProgress()letprogressView= progress.show(frame: rect, message:"Loading...", style:MyStyle())
view.addSubview(progressView!)
progress.dismiss(progress: progressView!)

at Rtio

UIWindow

letprogress=GradientCircularProgress()letratio:CGFloat=CGFloat(totalBytesWritten)/ CGFloat(totalBytesExpectedToWrite) progress.showAtRatio(style:MyStyle())
progress.updateRatio(ratio)
progress.dismiss()

addSubView

letprogress=GradientCircularProgress()letprogressView= progress.showAtRatio(frame: rect, display:true, style:MyStyle())
view.addSubview(progressView!)
progress.updateRatio(ratio)
progress.dismiss(progress: progressView!)

Update Message

UIWindow

letprogress=GradientCircularProgress()
progress.show(message:"Download\n0 / 4",MyStyle())
progress.updateMessage(message:"Download\n1 / 4")
progress.updateMessage(message:"Download\n2 / 4")
progress.updateMessage(message:"Download\n3 / 4")
progress.updateMessage(message:"Download\n4 / 4")
progress.updateMessage(message:"Completed!")
progress.dismiss()

addSubView

letprogress=GradientCircularProgress()letprogressView= progress.show(frame: rect, message:"Download\n0 / 4", style:MyStyle())
view.addSubview(progressView!)
progress.updateMessage(message:"Download\n1 / 4")
progress.updateMessage(message:"Download\n2 / 4")
progress.updateMessage(message:"Download\n3 / 4")
progress.updateMessage(message:"Download\n4 / 4")
progress.updateMessage(message:"Completed!")
progress.dismiss(progress: progressView!)

API

Use UIWindow

publicfunc showAtRatio(display:Bool=true, style:StyleProperty=Style())
public func show(style:StyleProperty=Style())
public func show(message:String, style:StyleProperty=Style())
public func dismiss()
public func dismiss(_ completionHandler:()->Void)->()

Use addSubView

publicfunc showAtRatio(frame:CGRect, display:Bool=true, style:StyleProperty=Style())->UIView?
public func show(frame:CGRect, style:StyleProperty= Style())->UIView?
public func show(frame:CGRect, message:String, style:StyleProperty= Style())->UIView?
public func dismiss(progress view:UIView)
public func dismiss(progress view:UIView, completionHandler:()->Void)->()

Common

publicfunc updateMessage(message message:String)
public func updateRatio(_ ratio:CGFloat)

License

Gradient Circular Progress is released under the MIT license. See LICENSE for details.

Author

Yukihiko Kagiyama (keygx) https://twitter.com/keygx

About

Customizable progress indicator library in Swift

Resources

Stars

0 stars

Watchers

5 watching

Forks

Releases

Packages

Contributors

Languages