Advertisement
Guest User

Untitled

a guest
Jul 13th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     CAShapeLayer *shapeLayer=[CAShapeLayer layer];
  2.     [shapeLayer setBounds:btn.frame];
  3.     [shapeLayer setFillColor:[[UIColor blueColor] CGColor]];
  4.     [shapeLayer setStrokeColor:[[UIColor blackColor] CGColor]];
  5.     [shapeLayer setLineWidth:1.0f];
  6.     UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:btn.frame cornerRadius:0.0];
  7.     [shapeLayer setPath:path.CGPath];
  8.     [[btn layer] addSublayer:shapeLayer];
  9.    
  10.     if ([shapeLayer animationForKey:@"linePhase"])
  11.         [shapeLayer removeAnimationForKey:@"linePhase"];
  12.     else {
  13.         CABasicAnimation *dashAnimation;
  14.         dashAnimation = [CABasicAnimation
  15.                          animationWithKeyPath:@"lineDashPhase"];
  16.         [dashAnimation setFromValue:[NSNumber numberWithFloat:0.0f]];
  17.         [dashAnimation setToValue:[NSNumber numberWithFloat:15.0f]];
  18.         [dashAnimation setDuration:0.75f];
  19.         [dashAnimation setRepeatCount:10000];
  20.         [shapeLayer addAnimation:dashAnimation forKey:@"linePhase"];
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement