Giter Site home page Giter Site logo

maniramezan / gradientcircularprogress Goto Github PK

View Code? Open in Web Editor NEW

This project forked from keygx/gradientcircularprogress

0.0 1.0 1.0 614 KB

Customizable progress indicator library in Swift

License: MIT License

Swift 98.53% Ruby 0.49% Objective-C 0.99%

gradientcircularprogress's Introduction

Gradient Circular Progress

Customizable progress indicator library in Swift

Requirements

  • Swift 5.1
  • iOS 8.0 or later

Screen Shots

  • All preset styles

  • Example Use AddSubView

Installation

Carthage

github "keygx/GradientCircularProgress"

CocoaPods

pod 'GradientCircularProgress', :git => 'https://github.com/keygx/GradientCircularProgress'

Swift versions support

  • Swift 5.1, tag "swift5.1"
  • Swift 5, tag "swift5"
  • Swift 4.2, tag "swift4.2"
  • Swift 4.1, tag "swift4.1"
  • Swift 4.0, tag "swift4.0"

Style Settings

Please make your original styles

  • Define custom style structs that implements the StyleProperty Protocol

MyStyle.swift

import GradientCircularProgress

public struct MyStyle : StyleProperty {
    /*** style properties **********************************************************************************/
    
    // Progress Size
    public var progressSize: CGFloat = 200
    
    // Gradient Circular
    public var arcLineWidth: CGFloat = 18.0
    public var startArcColor: UIColor = UIColor.clear()
    public var endArcColor: UIColor = UIColor.orange()
    
    // Base Circular
    public var baseLineWidth: CGFloat? = 19.0
    public var baseArcColor: UIColor? = UIColor.darkGray()
    
    // Ratio
    public var ratioLabelFont: UIFont? = UIFont(name: "Verdana-Bold", size: 16.0)
    public var ratioLabelFontColor: UIColor? = UIColor.white()
    
    // Message
    public var messageLabelFont: UIFont? = UIFont.systemFont(ofSize: 16.0)
    public var messageLabelFontColor: UIColor? = UIColor.white()
    
    // Background
    public var backgroundStyle: BackgroundStyles = .dark
    
    // Dismiss
    public var dismissTimeInterval: Double? = 0.0 // 'nil' for default setting.
    
    /*** style properties **********************************************************************************/
    
    public init() {}
}

Usage

import GradientCircularProgress

Basic

UIWindow

let progress = GradientCircularProgress()

progress.show(message: "Loading...", MyStyle())

progress.dismiss()

addSubView

let progress = GradientCircularProgress()

let progressView = progress.show(frame: rect, message: "Loading...", style: MyStyle())
view.addSubview(progressView!)

progress.dismiss(progress: progressView!)

at Rtio

UIWindow

let progress = GradientCircularProgress()

let ratio: CGFloat = CGFloat(totalBytesWritten) / CGFloat(totalBytesExpectedToWrite)        
progress.showAtRatio(style: MyStyle())

progress.updateRatio(ratio)

progress.dismiss()

addSubView

let progress = GradientCircularProgress()

let progressView = progress.showAtRatio(frame: rect, display: true, style: MyStyle())
view.addSubview(progressView!)

progress.updateRatio(ratio)

progress.dismiss(progress: progressView!)

Update Message

UIWindow

let progress = 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

let progress = GradientCircularProgress()

let progressView = 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

public func 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

public func 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

public func 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

gradientcircularprogress's People

Contributors

elder004 avatar keygx avatar maniramezan avatar sora0077 avatar

Watchers

 avatar

Forkers

popixels

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.