Objective c UIView要移动和后退的动画
我希望有一个视图上的动画,它将在x上向右移动2个像素,在x上向左移动2个像素 我有这个不透明度,我希望调整它,使它Objective c UIView要移动和后退的动画,objective-c,Objective C,我希望有一个视图上的动画,它将在x上向右移动2个像素,在x上向左移动2个像素 我有这个不透明度,我希望调整它,使它 CABasicAnimation *theAnimation; theAnimation=[CABasicAnimation animationWithKeyPath:@"opacity"]; theAnimation.duration=1.0; theAnimation.repeatCount=HUGE_VALF; theAnimatio
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"opacity"];
theAnimation.duration=1.0;
theAnimation.repeatCount=HUGE_VALF;
theAnimation.autoreverses=YES;
theAnimation.fromValue=[NSNumber numberWithFloat:1.0];
theAnimation.toValue=[NSNumber numberWithFloat:0.3];
[image.layer addAnimation:theAnimation forKey:@"animateOpacity"];
如果只希望动画出现一次,则可以跳过几个抽象级别并使用基于块的视图动画
[UIView animateWithDuration:1.f
delay:0
options:UIViewAnimationOptionAutoreverse
animations:^{
view.transform = CGAffineTransformMakeTranslation(2.f, 0.f);
} completion:^(BOOL finished) {
view.transform = CGAffineTransformIdentity;
}];
这将对两点进行翻译,然后在完成时将其删除通过阅读文档,您可以学到很多东西。例如,您可以了解UIViewAnimationOptionRepeat:“无限期地重复动画”。感谢它与Repeat一起工作。但现在我无法将另一个选项设置为curve。您可以使用逻辑或管道角色分隔选项