Customizable progress indicator library in Swift
- Swift 2.2
- iOS 8.0 or later
- Preset style: BlueDarkStyle.swift
- All preset styles
- Example Use AddSubView
###CocoaPods
- PodFile [Sample/PodFile]
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'GradientCircularProgress', :git => 'https://github.com/keygx/GradientCircularProgress'
- install
$ pod install
###Carthage
- Cartfile
github "keygx/GradientCircularProgress"
$ carthage update
- install
To integrate "GradientCircularProgress.framework" into your Xcode project
Please make your original styles
- Define custom style structs that implements the StyleProperty Protocol
import GradientCircularProgress
publicstructMyStyle:StyleProperty{
/*** style properties **********************************************************************************/
// Progress Size
publicvarprogressSize:CGFloat=200
// Gradient Circular
publicvararcLineWidth:CGFloat=18.0publicvarstartArcColor:UIColor=UIColor.clearColor()publicvarendArcColor:UIColor=UIColor.orangeColor()
// Base Circular
publicvarbaseLineWidth:CGFloat?=19.0publicvarbaseArcColor:UIColor?=UIColor.darkGrayColor()
// Ratio
publicvarratioLabelFont:UIFont?=UIFont(name:"Verdana-Bold", size:16.0)publicvarratioLabelFontColor:UIColor?=UIColor.whiteColor()
// Message
publicvarmessageLabelFont:UIFont?=UIFont.systemFontOfSize(16.0)publicvarmessageLabelFontColor:UIColor?=UIColor.whiteColor()
// Background
publicvarbackgroundStyle:BackgroundStyles=.Dark
/*** style properties **********************************************************************************/
publicinit(){}}import GradientCircularProgressletprogress=GradientCircularProgress()
progress.show(message:"Loading...",MyStyle())
progress.dismiss()letprogress=GradientCircularProgress()letprogressView= progress.show(frame: rect, message:"Loading...", style:MyStyle())
view.addSubview(progressView!)
progress.dismiss(progress: progressView!)letprogress=GradientCircularProgress()letratio:CGFloat=CGFloat(totalBytesWritten)/ CGFloat(totalBytesExpectedToWrite) progress.showAtRatio(style:MyStyle())
progress.updateRatio(ratio)
progress.dismiss()letprogress=GradientCircularProgress()letprogressView= progress.showAtRatio(frame: rect, display:true, style:MyStyle())
view.addSubview(progressView!)
progress.updateRatio(ratio)
progress.dismiss(progress: progressView!)letprogress=GradientCircularProgress()
progress.show(message:"Download\n0 / 4",MyStyle())
progress.show(message:"Download\n1 / 4",MyStyle())
progress.show(message:"Download\n2 / 4",MyStyle())
progress.show(message:"Download\n3 / 4",MyStyle())
progress.show(message:"Download\n4 / 4",MyStyle())lettime=dispatch_time(DISPATCH_TIME_NOW,Int64(0.8* Double(NSEC_PER_SEC)))dispatch_after(time,dispatch_get_main_queue()){self.progress.updateMessage(message:"Completed!")self.progress.dismiss()}letprogress=GradientCircularProgress()letprogressView= progress.show(frame: rect, message:"Download\n0 / 4", style:MyStyle())
view.addSubview(progressView!)
progress.show(message:"Download\n1 / 4",MyStyle())
progress.show(message:"Download\n2 / 4",MyStyle())
progress.show(message:"Download\n3 / 4",MyStyle())
progress.show(message:"Download\n4 / 4",MyStyle())lettime=dispatch_time(DISPATCH_TIME_NOW,Int64(0.8* Double(NSEC_PER_SEC)))dispatch_after(time,dispatch_get_main_queue()){self.progress.updateMessage(message:"Completed!")self.progress.dismiss(progress: progressView!)}letprogress=GradientCircularProgress()~~
progress.showAtRatio(style:BlueDarkStyle())leturl=NSURL(string:"http://example.com/download/dummy.mp4")letconfig=NSURLSessionConfiguration.defaultSessionConfiguration()letsession=NSURLSession(configuration: config, delegate:self, delegateQueue:NSOperationQueue.mainQueue())lettask= session.downloadTaskWithURL(url!)
task.resume()~~
// Delegate
func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64){letratio:CGFloat=CGFloat(totalBytesWritten)/ CGFloat(totalBytesExpectedToWrite)
progress.updateRatio(ratio)}
// Delegate
func URLSession(session:NSURLSession, downloadTask:NSURLSessionDownloadTask, didFinishDownloadingToURL location:NSURL){
progress.dismiss()}letprogress=GradientCircularProgress()~~
progress.showAtRatio(style:BlueDarkStyle())Alamofire.request(.GET,"http://example.com/download/dummy.mp4").response{(request, response, data, error)inself.progress.dismiss()}.progress{(bytesRead, totalBytesRead, totalBytesExpectedToRead)inletratio:CGFloat=CGFloat(totalBytesRead)/ CGFloat(totalBytesExpectedToRead)
// Call main thread.
dispatch_async(dispatch_get_main_queue(),{self.progress.updateRatio(ratio)})}publicfunc showAtRatio(display display:Bool=true, style:StyleProperty=Style())
public func show(style style:StyleProperty=Style())
public func show(message message:String, style:StyleProperty=Style())
public func dismiss()
public func dismiss(completionHandler:()->Void)->()publicfunc showAtRatio(frame frame:CGRect, display:Bool=true, style:StyleProperty=Style())->UIView?
public func show(frame frame:CGRect, style:StyleProperty= Style())->UIView?
public func show(frame frame:CGRect, message:String, style:StyleProperty= Style())->UIView?
public func dismiss(progress view:UIView)
public func dismiss(progress view:UIView, completionHandler:()->Void)->()publicfunc updateMessage(message message:String)
public func updateRatio(ratio:CGFloat)Gradient Circular Progress is released under the MIT license. See LICENSE for details.
Yukihiko Kagiyama (keygx) https://twitter.com/keygx







