ATCircularProgressView 1.0.1

ATCircularProgressView 1.0.1

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最新版本Nov 2016
SwiftSwift 版本3.0
SPM支持 SPM

Adam Tecle 维护。



ATCircularProgressView

这是一个为 iOS 设计的非常简单的环形进度视图,您可以在 Storyboard 中或通过代码进行自定义。它轻量且性能卓越 - 使用 CAShapeLayers 进行绘图并使用 CADisplayLink 更新进度。

用法

您可以在代码中创建实例,也可以通过将 UIView 拖动到 Storyboard 并设置子类和模块来创建。

以下是如何设置进度的示例

Swift

progressView.setProgress(value: random, animated: true, duration: 1, completion: nil)

Objective-C

[self.progressView setProgressWithValue:0.5 animated:YES duration:1 completion:nil];

如果您想在进度变化时执行某些工作,例如更新标签,请设置 progressChanged 属性

Swift

 let progressChanged: (CircularProgressView, CGFloat) -> () = { [unowned self]
      (progressView, progress) in
      let value = Int(progress * 100.0)
      self.centralLabel.text = "\(value)%"
}

progressView.progressChanged = progressChanged

Objective-C

   __weak typeof(self) weakSelf = self;
    self.progressView.progressChanged =  ^(CircularProgressView *progressView, CGFloat progress) {
        __strong typeof(self) self = weakSelf;
        self.label.text = [NSString stringWithFormat:@"%ld", (long)progress];
    };

CircularProgressView 可在 Storyboard 中进行设计。您可以设置边界/进度层的宽度和颜色以及进度值。

查看演示项目,进行尝试。

待办事项

  • iOS 6+ 支持
  • 重构
  • 编写测试
  • 修复边界/进度层不同宽度下的空格问题
  • 设置图片

作者

@admtcl

MIT 许可证

The MIT License (MIT)

Copyright (c) 2016 Adam Tecle

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.