Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions SXWaveAnimate/SXWaveAnimate/Classes/SXWaveView/SXWaveView.m
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,17 @@ - (void)addAnimateWithType:(int)type
transformRoate.repeatCount = self.isEndless == YES ? MAXFLOAT : 2;
[self.rotateImg.layer addAnimation:transformRoate forKey:viewRotationKey];

__weak __typeof(&*self)weakSelf = self;
void(^acallBack)(CGFloat start) = ^(CGFloat start) {
CAKeyframeAnimation * moveAction = [CAKeyframeAnimation animationWithKeyPath:@"position.x"];
moveAction.values = [NSArray arrayWithObjects:[NSNumber numberWithFloat:-60],[NSNumber numberWithFloat:start],nil];
moveAction.duration = 4;
// moveAction.autoreverses = YES;
moveAction.repeatCount = MAXFLOAT;
[weakSelf.bigImg.layer addAnimation:moveAction forKey:viewMoveKey];
};


if (type == 0) {
CGFloat avgScore = self.precent;
[UIView animateWithDuration:4.0 animations:^{
Expand All @@ -186,6 +197,10 @@ - (void)addAnimateWithType:(int)type
self.bigImg.top = -20;
}
self.bigImg.left = 0;
} completion:^(BOOL finished) {
if (self.endless == YES) {
acallBack(self.bigImg.layer.position.x);
}
}];
}else if (type == 1){
CGFloat avgScore = self.precent;
Expand All @@ -197,7 +212,12 @@ - (void)addAnimateWithType:(int)type
self.bigImg.top = -20;
}
self.bigImg.left = 0;
} completion:^(BOOL finished) {
if (self.endless == YES) {
acallBack(self.bigImg.layer.position.x);
}
}];

}else if (type == 2){
CGFloat avgScore = self.precent;
[UIView animateWithDuration:2.0 animations:^{
Expand All @@ -211,6 +231,9 @@ - (void)addAnimateWithType:(int)type
}
self.bigImg.left = 0;
}];
if (self.endless == YES) {
acallBack(self.bigImg.layer.position.x);
}
}];
}
}
Expand Down