Add a public API for setting animation's duration

This commit is contained in:
Arkadiusz Holko
2013-05-19 17:26:26 +02:00
parent 85ed70e707
commit 3a15d33439
2 changed files with 21 additions and 1 deletions

View File

@@ -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
View 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;