sur*_*her 0 iphone xcode animation objective-c
我想做边框动画,比如将标签的颜色从一种颜色改为两种或多种不同颜色的发光功能.
任何人都可以告诉我如何做到这一点.任何帮助将不胜感激
CALayer的动画应该让你开始.
例如,我使用此代码为按钮的边框宽度设置动画(它使边框更粗,并使背面恢复正常两次).
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"];
Run Code Online (Sandbox Code Playgroud)
您也可以为颜色做类似的事情,但您可能需要使用一些UIView动画块
[UIView animateWithDuration:0.4
animations:^{
// one animation
}
completion:^(BOOL finished){
// ... completion stuff
//other animation when the first one completes
}
];
Run Code Online (Sandbox Code Playgroud)
有关CALayere的更多信息,请访问:http://www.raywenderlich.com/2502/introduction-to-calayers-tutorial 或Core Animation:https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual /CoreAnimation_guide/Articles/Headstart.html/http://www.macresearch.org/tutorial-intro-core-animation
| 归档时间: |
|
| 查看次数: |
1620 次 |
| 最近记录: |