Showing
2 changed files
with
63 additions
and
42 deletions
| @@ -225,29 +225,24 @@ | @@ -225,29 +225,24 @@ | ||
| 225 | frame.origin.x = (self.bounds.size.width - size.width)/2.0; | 225 | frame.origin.x = (self.bounds.size.width - size.width)/2.0; |
| 226 | frame.size = size; | 226 | frame.size = size; |
| 227 | self.textLayer.frame = frame; | 227 | self.textLayer.frame = frame; |
| 228 | - | 228 | + |
| 229 | - CABasicAnimation* rotationAnimation; | 229 | + [self addRotationAnimationIfNeeded]; |
| 230 | - rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; | ||
| 231 | - rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI]; | ||
| 232 | - [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | ||
| 233 | - rotationAnimation.duration = 0.1; | ||
| 234 | - rotationAnimation.repeatCount = 0;//你可以设置到最大的整数值 | ||
| 235 | - rotationAnimation.cumulative = NO; | ||
| 236 | - rotationAnimation.removedOnCompletion = NO; | ||
| 237 | - rotationAnimation.fillMode = kCAFillModeForwards; | ||
| 238 | - [self.textLayer addAnimation:rotationAnimation forKey:@"Rotation"]; | ||
| 239 | - | ||
| 240 | } | 230 | } |
| 241 | } | 231 | } |
| 242 | 232 | ||
| 243 | -(CABasicAnimation*)fadeAnimation | 233 | -(CABasicAnimation*)fadeAnimation |
| 244 | { | 234 | { |
| 245 | - CABasicAnimation* fadeAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"]; | 235 | + if (self.displayAnimated) { |
| 246 | - fadeAnimation.fromValue = [NSNumber numberWithFloat:0.0]; | 236 | + CABasicAnimation* fadeAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"]; |
| 247 | - fadeAnimation.toValue = [NSNumber numberWithFloat:1.0]; | 237 | + fadeAnimation.fromValue = [NSNumber numberWithFloat:0.0]; |
| 248 | - fadeAnimation.duration = 2.0; | 238 | + fadeAnimation.toValue = [NSNumber numberWithFloat:1.0]; |
| 249 | - | 239 | + fadeAnimation.duration = 2.0; |
| 250 | - return fadeAnimation; | 240 | + |
| 241 | + return fadeAnimation; | ||
| 242 | + } | ||
| 243 | + else { | ||
| 244 | + return nil; | ||
| 245 | + } | ||
| 251 | } | 246 | } |
| 252 | 247 | ||
| 253 | -(void)addAnimationIfNeededWithProgressLine:(UIBezierPath *)progressline | 248 | -(void)addAnimationIfNeededWithProgressLine:(UIBezierPath *)progressline |
| @@ -277,4 +272,20 @@ | @@ -277,4 +272,20 @@ | ||
| 277 | } | 272 | } |
| 278 | } | 273 | } |
| 279 | 274 | ||
| 275 | +- (void)addRotationAnimationIfNeeded | ||
| 276 | +{ | ||
| 277 | + if (self.displayAnimated) { | ||
| 278 | + CABasicAnimation* rotationAnimation; | ||
| 279 | + rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; | ||
| 280 | + rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI]; | ||
| 281 | + [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | ||
| 282 | + rotationAnimation.duration = 0.1; | ||
| 283 | + rotationAnimation.repeatCount = 0;//你可以设置到最大的整数值 | ||
| 284 | + rotationAnimation.cumulative = NO; | ||
| 285 | + rotationAnimation.removedOnCompletion = NO; | ||
| 286 | + rotationAnimation.fillMode = kCAFillModeForwards; | ||
| 287 | + [self.textLayer addAnimation:rotationAnimation forKey:@"Rotation"]; | ||
| 288 | + } | ||
| 289 | +} | ||
| 290 | + | ||
| 280 | @end | 291 | @end |
| @@ -325,14 +325,6 @@ | @@ -325,14 +325,6 @@ | ||
| 325 | [progressline setLineCapStyle:kCGLineCapSquare]; | 325 | [progressline setLineCapStyle:kCGLineCapSquare]; |
| 326 | _chartBottomLine.path = progressline.CGPath; | 326 | _chartBottomLine.path = progressline.CGPath; |
| 327 | _chartBottomLine.strokeColor = [_chartBorderColor CGColor];; | 327 | _chartBottomLine.strokeColor = [_chartBorderColor CGColor];; |
| 328 | - | ||
| 329 | - CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; | ||
| 330 | - pathAnimation.duration = 0.5; | ||
| 331 | - pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | ||
| 332 | - pathAnimation.fromValue = @0.0f; | ||
| 333 | - pathAnimation.toValue = @1.0f; | ||
| 334 | - [_chartBottomLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; | ||
| 335 | - | ||
| 336 | _chartBottomLine.strokeEnd = 1.0; | 328 | _chartBottomLine.strokeEnd = 1.0; |
| 337 | 329 | ||
| 338 | [self.layer addSublayer:_chartBottomLine]; | 330 | [self.layer addSublayer:_chartBottomLine]; |
| @@ -354,16 +346,9 @@ | @@ -354,16 +346,9 @@ | ||
| 354 | [progressLeftline setLineCapStyle:kCGLineCapSquare]; | 346 | [progressLeftline setLineCapStyle:kCGLineCapSquare]; |
| 355 | _chartLeftLine.path = progressLeftline.CGPath; | 347 | _chartLeftLine.path = progressLeftline.CGPath; |
| 356 | _chartLeftLine.strokeColor = [_chartBorderColor CGColor]; | 348 | _chartLeftLine.strokeColor = [_chartBorderColor CGColor]; |
| 357 | - | ||
| 358 | - CABasicAnimation *pathLeftAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; | ||
| 359 | - pathLeftAnimation.duration = 0.5; | ||
| 360 | - pathLeftAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | ||
| 361 | - pathLeftAnimation.fromValue = @0.0f; | ||
| 362 | - pathLeftAnimation.toValue = @1.0f; | ||
| 363 | - [_chartLeftLine addAnimation:pathLeftAnimation forKey:@"strokeEndAnimation"]; | ||
| 364 | - | ||
| 365 | _chartLeftLine.strokeEnd = 1.0; | 349 | _chartLeftLine.strokeEnd = 1.0; |
| 366 | 350 | ||
| 351 | + [self addBorderAnimationIfNeeded]; | ||
| 367 | [self.layer addSublayer:_chartLeftLine]; | 352 | [self.layer addSublayer:_chartLeftLine]; |
| 368 | } | 353 | } |
| 369 | 354 | ||
| @@ -385,14 +370,8 @@ | @@ -385,14 +370,8 @@ | ||
| 385 | _chartLevelLine.path = progressline.CGPath; | 370 | _chartLevelLine.path = progressline.CGPath; |
| 386 | 371 | ||
| 387 | _chartLevelLine.strokeColor = PNLightGrey.CGColor; | 372 | _chartLevelLine.strokeColor = PNLightGrey.CGColor; |
| 388 | - | 373 | + |
| 389 | - CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; | 374 | + [self addSeparatorAnimationIfNeeded]; |
| 390 | - pathAnimation.duration = 0.5; | ||
| 391 | - pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | ||
| 392 | - pathAnimation.fromValue = @0.0f; | ||
| 393 | - pathAnimation.toValue = @1.0f; | ||
| 394 | - [_chartLevelLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; | ||
| 395 | - | ||
| 396 | _chartLevelLine.strokeEnd = 1.0; | 375 | _chartLevelLine.strokeEnd = 1.0; |
| 397 | 376 | ||
| 398 | [self.layer addSublayer:_chartLevelLine]; | 377 | [self.layer addSublayer:_chartLevelLine]; |
| @@ -404,6 +383,37 @@ | @@ -404,6 +383,37 @@ | ||
| 404 | } | 383 | } |
| 405 | } | 384 | } |
| 406 | 385 | ||
| 386 | +- (void)addBorderAnimationIfNeeded | ||
| 387 | +{ | ||
| 388 | + if (self.displayAnimated) { | ||
| 389 | + CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; | ||
| 390 | + pathAnimation.duration = 0.5; | ||
| 391 | + pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | ||
| 392 | + pathAnimation.fromValue = @0.0f; | ||
| 393 | + pathAnimation.toValue = @1.0f; | ||
| 394 | + [_chartBottomLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; | ||
| 395 | + | ||
| 396 | + CABasicAnimation *pathLeftAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; | ||
| 397 | + pathLeftAnimation.duration = 0.5; | ||
| 398 | + pathLeftAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | ||
| 399 | + pathLeftAnimation.fromValue = @0.0f; | ||
| 400 | + pathLeftAnimation.toValue = @1.0f; | ||
| 401 | + [_chartLeftLine addAnimation:pathLeftAnimation forKey:@"strokeEndAnimation"]; | ||
| 402 | + } | ||
| 403 | +} | ||
| 404 | + | ||
| 405 | +- (void)addSeparatorAnimationIfNeeded | ||
| 406 | +{ | ||
| 407 | + if (self.displayAnimated) { | ||
| 408 | + CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; | ||
| 409 | + pathAnimation.duration = 0.5; | ||
| 410 | + pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | ||
| 411 | + pathAnimation.fromValue = @0.0f; | ||
| 412 | + pathAnimation.toValue = @1.0f; | ||
| 413 | + [_chartLevelLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; | ||
| 414 | + } | ||
| 415 | +} | ||
| 416 | + | ||
| 407 | - (void)viewCleanupForCollection:(NSMutableArray *)array | 417 | - (void)viewCleanupForCollection:(NSMutableArray *)array |
| 408 | { | 418 | { |
| 409 | if (array.count) { | 419 | if (array.count) { |
-
Please register or login to post a comment