动画组合(uber启动时的等待效果代码)
- (void)startAnimation {
self.layer.masksToBounds= 0;
self.layer.cornerRadius= 50;
if (self.layer.sublayers== nil) {
[selfsetUpAnimation];
}
self.layer.speed= 1;
}
- (void)setUpAnimation {
CABasicAnimation *posAnim = [CABasicAnimationanimationWithKeyPath:@"transform.scale"];
posAnim.fromValue= @(0.01);
posAnim.toValue= @(1);
posAnim.duration= 1;
posAnim.timingFunction= [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut];
CABasicAnimation *opacity = [CABasicAnimationanimationWithKeyPath:@"opacity"];
opacity.fromValue= @(1);
opacity.toValue= @(0);
opacity.duration= 1;
opacity.timingFunction= [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut];
CAAnimationGroup *animGroup = [CAAnimationGroupanimation];
animGroup.animations= [NSArrayarrayWithObjects:posAnim, opacity,nil];
animGroup.duration= 1;
animGroup.repeatCount= HUGE;
[self.layeraddAnimation:animGroupforKey:nil];}
self.layer.cornerRadius= 50;
if (self.layer.sublayers== nil) {
[selfsetUpAnimation];
}
self.layer.speed= 1;
}
- (void)setUpAnimation {
CABasicAnimation *posAnim = [CABasicAnimationanimationWithKeyPath:@"transform.scale"];
posAnim.fromValue= @(0.01);
posAnim.toValue= @(1);
posAnim.duration= 1;
posAnim.timingFunction= [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut];
CABasicAnimation *opacity = [CABasicAnimationanimationWithKeyPath:@"opacity"];
opacity.fromValue= @(1);
opacity.toValue= @(0);
opacity.duration= 1;
opacity.timingFunction= [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut];
CAAnimationGroup *animGroup = [CAAnimationGroupanimation];
animGroup.animations= [NSArrayarrayWithObjects:posAnim, opacity,nil];
animGroup.duration= 1;
animGroup.repeatCount= HUGE;
[self.layeraddAnimation:animGroupforKey:nil];}