mirror of
https://github.com/zhigang1992/CERoundProgressView.git
synced 2026-03-26 08:44:34 +08:00
Add a public API for setting animation's duration
This commit is contained in:
@@ -16,5 +16,6 @@
|
||||
@property (nonatomic, assign) float startAngle; // 0..2π
|
||||
@property (nonatomic, retain) UIColor *tintColor UI_APPEARANCE_SELECTOR;
|
||||
@property (nonatomic, retain) UIColor *trackColor UI_APPEARANCE_SELECTOR;
|
||||
@property (nonatomic, assign) float animationDuration; // greater than 0 (in seconds); default value: 0.25
|
||||
|
||||
@end
|
||||
|
||||
21
RoundProgress/CERoundProgressView.m
Normal file → Executable file
21
RoundProgress/CERoundProgressView.m
Normal file → Executable file
@@ -17,6 +17,8 @@
|
||||
|
||||
@implementation CERoundProgressView
|
||||
|
||||
@synthesize animationDuration = _animationDuration;
|
||||
|
||||
+ (Class) layerClass
|
||||
{
|
||||
return [CERoundProgressLayer class];
|
||||
@@ -79,7 +81,7 @@
|
||||
if(animated)
|
||||
{
|
||||
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"progress"];
|
||||
animation.duration = 0.25;
|
||||
animation.duration = self.animationDuration;
|
||||
animation.fromValue = [NSNumber numberWithFloat:layer.progress];
|
||||
animation.toValue = [NSNumber numberWithFloat:progress];
|
||||
[layer addAnimation:animation forKey:@"progressAnimation"];
|
||||
@@ -93,6 +95,23 @@
|
||||
}
|
||||
}
|
||||
|
||||
#define DEFAULT_ANIMATION_DURATION 0.25
|
||||
|
||||
- (float)animationDuration
|
||||
{
|
||||
if (!_animationDuration) {
|
||||
_animationDuration = DEFAULT_ANIMATION_DURATION;
|
||||
}
|
||||
return _animationDuration;
|
||||
}
|
||||
|
||||
- (void)setAnimationDuration:(float)animationDuration
|
||||
{
|
||||
if (animationDuration > 0) {
|
||||
_animationDuration = animationDuration;
|
||||
}
|
||||
}
|
||||
|
||||
- (UIColor *)tintColor
|
||||
{
|
||||
CERoundProgressLayer *layer = (CERoundProgressLayer *)self.layer;
|
||||
|
||||
Reference in New Issue
Block a user