大佬教程收集整理的这篇文章主要介绍了iphone – 像核心动画老虎机一样在z轴上旋转,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
- (void) makeAnim1{ //downWARD animation [UIView animateWithDuration:1.5 delay:0.15 options: UIViewAnimationCurveLinear animations:^{ carousel.frame = CGRectOffset(carousel.frame,650); } completion:^(BOOL finished){ //task after an animation ends [self performSELEctor:@SELEctor(makeAnim1_1) withObject:nil afterDelay:2.0]; NSLog(@"Done!"); }]; } - (void) makeAnim1_1{ //upWARD animation [UIView animateWithDuration:1.5 delay:0.1 options: UIViewAnimationCurveLinear animations:^{ carousel.frame = CGRectOffset(carousel.frame,-650); } completion:^(BOOL finished){ NSLog(@"Done!"); }]; }
但它只会上下移动UIView.如何让它像Slot机器一样旋转,但只包含一个图像或视图.像在z轴上旋转一样.但要让它看起来像包含多个图像.
谢谢您的帮助.
// rotate pi/2 degrees clockwise carousel.transform = CGAffineTransformMakeRotation(M_PI_2);
如果你需要进行更高级的变换,比如围绕另一个轴旋转,那么你需要使用一点Core Animation并设置views层的transform属性(它采用CATransform3D而不是CGAffineTransform).
与所有Core Animation代码一样,您需要导入QuartzCore.framework并在代码中包含QuartzCore / QuartzCore.h.
您正在进行的上述动画是UIView动画,这些动画仅用于为视图设置动画,但您要求的动画需要更高级的视图层动画.我建议您查看CABasicAnimation的文档,还可以查看iOS核心动画编程指南以了解更多信息.
您可以为视图图层的x旋转设置动画,如下所示:
CABasicAnimation *slotAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.x"]; [slotAnimation setToValue:[NSnumber numberWithFloat:M_PI_2]]; // animation customizations like duration and timing // that you can read about in the documentation [[carousel layer] addAnimation:slotAnimation forKey:@"mySlotAnimation"];
上面的代码确实会围绕x轴旋转视图,但是在没有透视的情况下看起来会非常愚蠢(搜索SO的“透视核心动画”,之前已经被问过).可能需要进行大量调整以获得正确的外观,但这应该足以让您入门.
以上是大佬教程为你收集整理的iphone – 像核心动画老虎机一样在z轴上旋转全部内容,希望文章能够帮你解决iphone – 像核心动画老虎机一样在z轴上旋转所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。