GradientCircularProgress, 快速,可以定制的进度指示器库

分享于 

8分钟阅读

GitHub

  繁體 雙語
Customizable progress indicator library in Swift
  • 源代码名称:GradientCircularProgress
  • 源代码网址:http://www.github.com/keygx/GradientCircularProgress
  • GradientCircularProgress源代码文档
  • GradientCircularProgress源代码下载
  • Git URL:
    git://www.github.com/keygx/GradientCircularProgress.git
    Git Clone代码到本地:
    git clone http://www.github.com/keygx/GradientCircularProgress
    Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/keygx/GradientCircularProgress
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
    
    渐变循环进度

    Swift中可以定制的进度指示器库

    要求

    • Swift 4.0
    • iOS 8.0或者更高版本

    屏幕快照

    • 所有预设样式

    • 示例使用 AddSubView

    安装

    ###Carthage

    • Cartfile
    
    github"keygx/GradientCircularProgress"
    
    
    
    

    或者

    
    github"keygx/GradientCircularProgress""branch-name"
    
    
    
    

    或者

    
    github"keygx/GradientCircularProgress""tag"
    
    
    
    
    • 安装
    
    $ carthage update
    
    
    
    

    将"gradientcircularprogress。框架"集成到Xcode项目中

    ###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'] = '3.0'
    
    
     end
    
    
     end
    
    
     end
    
    
    
    end
    
    
    
    

    或者

    
    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'] = '3.0'
    
    
     end
    
    
     end
    
    
     end
    
    
    
    end
    
    
    
    

    或者

    
    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'] = '3.0'
    
    
     end
    
    
     end
    
    
     end
    
    
    
    end
    
    
    
    
    • 安装
     
    $ pod install
    
    
    
     

    样式设置

    请把你的原始款式 make。

    • 定义实现StyleProperty协议的自定义样式结构

    MyStyle.swift

    importGradientCircularProgresspublicstructMyStyle : StyleProperty {
     /*** style properties **********************************************************************************/// Progress Sizepublicvar progressSize: CGFloat =200// Gradient Circularpublicvar arcLineWidth: CGFloat =18.0publicvar startArcColor: UIColor = UIColor.clear()
     publicvar endArcColor: UIColor = UIColor.orange()
     // Base Circularpublicvar baseLineWidth: CGFloat?=19.0publicvar baseArcColor: UIColor?= UIColor.darkGray()
     // Ratiopublicvar ratioLabelFont: UIFont?=UIFont(name: "Verdana-Bold", size: 16.0)
     publicvar ratioLabelFontColor: UIColor?= UIColor.white()
     // Messagepublicvar messageLabelFont: UIFont?= UIFont.systemFont(ofSize: 16.0)
     publicvar messageLabelFontColor: UIColor?= UIColor.white()
     // Backgroundpublicvar backgroundStyle: BackgroundStyles =. dark// Dismisspublicvar dismissTimeInterval:Double?=0.0// 'nil' for default setting. 
     /*** style properties **********************************************************************************/publicinit() {}
    }

    用法

    importGradientCircularProgress

    基本

    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!)

    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!)

    更新消息

    UIWindow
    let progress =GradientCircularProgress()
    progress.show(message: "Downloadn0/4", MyStyle())
    progress.updateMessage(message: "Downloadn1/4")
    progress.updateMessage(message: "Downloadn2/4")
    progress.updateMessage(message: "Downloadn3/4")
    progress.updateMessage(message: "Downloadn4/4")
    progress.updateMessage(message: "Completed!")
    progress.dismiss()
    addSubView
    let progress =GradientCircularProgress()let progressView = progress.show(frame: rect, message: "Downloadn0/4", style: MyStyle())
    view.addSubview(progressView!)
    progress.updateMessage(message: "Downloadn1/4")
    progress.updateMessage(message: "Downloadn2/4")
    progress.updateMessage(message: "Downloadn3/4")
    progress.updateMessage(message: "Downloadn4/4")
    progress.updateMessage(message: "Completed!")
    progress.dismiss(progress: progressView!)

    API

    使用 UIWindow

    publicfuncshowAtRatio(display: Bool=true, style: StyleProperty =Style())publicfuncshow(style: StyleProperty =Style())publicfuncshow(message: String, style: StyleProperty =Style())publicfuncdismiss()publicfuncdismiss(_completionHandler: () ->Void) -> ()

    使用 addSubView

    publicfuncshowAtRatio(frame: CGRect, display: Bool=true, style: StyleProperty =Style()) -> UIView?publicfuncshow(frame: CGRect, style: StyleProperty =Style()) -> UIView?publicfuncshow(frame: CGRect, message: String, style: StyleProperty =Style()) -> UIView?publicfuncdismiss(progressview: UIView)publicfuncdismiss(progressview: UIView, completionHandler: () ->Void) -> ()

    通用

    publicfuncupdateMessage(messagemessage: String)publicfuncupdateRatio(_ratio: CGFloat)

    许可证

    梯度循环进度在MIT许可下发布。 详细信息请参阅许可证。

    作者

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


    相关文章