Cam*_*mus 3 animation shadow quartz-graphics ios
我想要做的是模拟按钮周围的脉冲.我可以使用发光效果来改变按钮图层的属性.但是,我无法让它变得生动.这是我到目前为止所尝试的:
UIColor *confirmButtonColor = self.btnConfirm.currentTitleColor;
self.btnConfirm.layer.shadowOffset = CGSizeZero;
self.btnConfirm.layer.masksToBounds = NO;
self.btnConfirm.layer.shadowColor = confirmButtonColor.CGColor;
self.btnConfirm.layer.shadowRadius = 6.0f;
self.btnConfirm.layer.shadowOpacity = .0f;
[UIView animateWithDuration:1.2 delay:5 options:UIViewAnimationCurveLinear animations:^{
self.btnConfirm.layer.shadowOpacity = 1.0f;
}completion:nil];
Run Code Online (Sandbox Code Playgroud)
发光没有动画; 我还尝试将所有代码放在动画中并且没有改变.是的,我导入Quartz.
谢谢
我不清楚你为什么没有工作(也许有人可以启发我们),但这有效:
UIColor *confirmButtonColor = self.btnConfirm.currentTitleColor;
self.btnConfirm.layer.shadowOffset = CGSizeZero;
self.btnConfirm.layer.masksToBounds = NO;
self.btnConfirm.layer.shadowColor = confirmButtonColor.CGColor;
self.btnConfirm.layer.shadowRadius = 6.0f;
self.btnConfirm.layer.shadowOpacity = 1.0f; // Note: You need the final value here
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"];
animation.fromValue = [NSNumber numberWithFloat:.0];
animation.toValue = [NSNumber numberWithFloat:1.0];
[self.btnConfirm.layer addAnimation:animation forKey:@"shadowOpacity"];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2743 次 |
| 最近记录: |