Reputation: 1378
I want to do border animation like changing the color of label form one color to two or more different colors with glowing functionality.
Can anyone please tell me how to do this. Any help will be appreciated
Upvotes: 0
Views: 1647
Reputation: 3650
CALayer's animation should get you started.
For example, I used this code to animate a button's border width (it makes the border thicker and the back to normal for two times).
CABasicAnimation* borderAnimation = [CABasicAnimation animationWithKeyPath:@"borderWidth"];
[borderAnimation setFromValue:[NSNumber numberWithFloat:2.0f]];
[borderAnimation setToValue:[NSNumber numberWithFloat:0.0f]];
[borderAnimation setRepeatCount:2.0];
[borderAnimation setAutoreverses:NO];
[borderAnimation setDuration:0.2f];
[self.addToCommandeBtn.layer addAnimation:borderAnimation forKey:@"animateBorder"];
You can do something similar for the color too, but you would probably need to use some UIView animation blocks
[UIView animateWithDuration:0.4
animations:^{
// one animation
}
completion:^(BOOL finished){
// ... completion stuff
//other animation when the first one completes
}
];
More info about CALayere here: http://www.raywenderlich.com/2502/introduction-to-calayers-tutorial or Core Animation here: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/Headstart.html / http://www.macresearch.org/tutorial-intro-core-animation
Upvotes: 5