ESArcProgressView 1.6.4

ESArcProgressView 1.6.4

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2015年6月

Bas van Kuijck 维护。



  • 作者
  • bvkuijck

用于 Apple Watch 项目的进度视图

示例

安装

手动安装

这些类有以下依赖项

  • QuartzCore 框架

用法

ESMultipleArcProgressView

#import <ESMultipleArcProgressView.h>

ESMultipleArcProgressView *v = [[ESMultipleArcProgressView alloc] initWithFrame:CGRectMake(40, 40, 200, 200)];
[self.view addSubview:v];

ESArcProgressView *pv = [[ESArcProgressView alloc] init];
[pv setProgress:0.5];
[pv setText:@"RUN"];
[pv setColor:[UIColor orangeColor]];
[v addArcProgressView:pv];

pv = [[ESArcProgressView alloc] init];
[pv setProgress:0.65];
[pv setText:@"WALK"];
[pv setColor:[UIColor greenColor]];
[v addArcProgressView:pv];

pv = [[ESArcProgressView alloc] init];
[pv setProgress:0.8];
[pv setText:@"REST"];
[pv setColor:[UIColor redColor]];
[v addArcProgressView:pv];
// To extract the UIImage:
UIImage *image = [v es_imageOfView];

ESArcProgressView

#import <ESArcProgressView.h>

ESArcProgressView *pv = [[ESArcProgressView alloc] initWithFrame:CGRectMake(20, 20, 200, 200)];
[pv setProgress:0.5];
[pv setColor:[UIColor orangeColor]];
[self.view addSubview:pv];
// To extract the UIImage:
UIImage *image = [pv es_imageOfView];

动画

#import <ESArcProgressView.h>

#include <easing.h>

ESArcProgressView *pv = [[ESArcProgressView alloc] initWithFrame:CGRectMake(20, 20, 200, 200)];
[pv setProgress:0];
[pv setColor:[UIColor orangeColor]];
[self.view addSubview:pv];

[pv animateTo:0.75 withDuration:1.0f withEasingFunction:BounceEaseOut withUpdateHandler:^(CGFloat animationProgress) {
    NSLog(@"animation progress: %.2f", animationProgress);
    if (animationProgress == 1.0f) {
        NSLog(@"animation finished");
    }
}];

ESArcProgressView

属性

属性 类型 描述 默认值
color UIColor 线的颜色 绿色
backgroundColor UIColor 线的背景色 默认 = 50% 透明于颜色
dotColor UIColor 线开始/结束处的中心点的颜色 白色
lineWidth CGFloat 线的宽度(即直径) 20
showZeroProgress BOOL 当进度为 0.0 时,是否应有可见的小线段 NO
showShadow BOOL 线是否有阴影 YES
centerDotStyle ESArcProgress-CenterDotStyle 中心点样式的位置 ESArcProgress-CenterDotStyle-BeginAndEnd
centerDotImage UIImage Using a custom image instead of 'center dot' nil
colorizeCenterDotImage BOOL 是否用 dotColor 着色 centerDotImage YES
progress CGFloat 百分比进度(从 0.0 - 1.0) 0.0
文字 NSString 在进度视图旁边显示文本标签 nil
multipleArcProgressView ESMultipleArc-ProgressView 这个实例所属的视图组 nil

ESArcProgressCenterDotStyle

typedef NS_ENUM(NSInteger, ESArcProgressCenterDotStyle) {
    ESArcProgressCenterDotStyleNone = 0,
    ESArcProgressCenterDotStyleBegin,
    ESArcProgressCenterDotStyleEnd,
    ESArcProgressCenterDotStyleBeginAndEnd
};

方法

animateTo:

以1.0秒的持续时间和线性缓动动画过渡到指定值

属性 类型 描述
toValue CGFloat 动画要过渡到的进度

animateTo:withDuration:

以1.0秒的持续时间和线性缓动动画过渡到指定值

属性 类型 描述
toValue CGFloat 动画要过渡到的进度
duration NSTimeInterval 动画的持续时间

animateTo:withDuration:withEasingFunction:

以1.0秒的持续时间和线性缓动动画过渡到指定值

属性 类型 描述
toValue CGFloat 动画要过渡到的进度
duration NSTimeInterval 动画的持续时间
easingFunction AHEasingFunction 有关可能的值,请参阅 AHEAsing

animateTo:withDuration:withEasingFunction:withUpdateHandler:

以1.0秒的持续时间和线性缓动动画过渡到指定值

属性 类型 描述
toValue CGFloat 动画要过渡到的进度
duration NSTimeInterval 动画的持续时间
easingFunction AHEasingFunction 有关可能的值,请参阅 AHEAsing
updateHandler void (^)(CGFloat animationProgress) 当动画进度发生变化时被调用的更新块

ESMultipleArcProgressView

属性

属性 类型 描述 默认值
margin CGFloat 进度视图之间的空间 1.0

方法


addArcProgressView:

向视图添加一个 ESArcProgressView。每个 ESArcProgressView 将被插入到前一个 ESArcProgressView 中。

参数 类型 描述
progressView ESArcProgressView 要添加的 ESArcProgressView

removeArcProgressView:

从视图堆栈中移除特定的 ESArcProgressView。此方法将根据需要重新定位剩余的进度视图。

参数 类型 描述
progressView ESArcProgressView 要移除的 ESArcProgressView

UIView (ESMultipleArcProgressViewGenerateUIImage)

es_imageOfView

此方法生成(并返回)一个 UIImage,它代表了当前实例视图的快照,并使用设备的缩放设置。

es_imageOfViewWithScale:

此方法生成(并返回)一个 UIImage,它代表了当前实例视图的快照,并使用特定的缩放设置。