Ios iPhone:在objective-c中创建滚动效果
我有以下功能,可以将UIView从屏幕的一侧移动到另一侧:Ios iPhone:在objective-c中创建滚动效果,ios,objective-c,core-animation,Ios,Objective C,Core Animation,我有以下功能,可以将UIView从屏幕的一侧移动到另一侧: -(void)animateView:(UIView *)p_view { CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position.x"]; animation.delegate = self; animation.fromValue = [NSNumber numberWithInteger:(p_vie
-(void)animateView:(UIView *)p_view {
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position.x"];
animation.delegate = self;
animation.fromValue = [NSNumber numberWithInteger:(p_view.frame.origin.x - p_view.frame.size.width)] ;
animation.toValue = [NSNumber numberWithInteger:[UIScreen mainScreen].bounds.size.width];
animation.duration = 0.8;
animation.autoreverses = NO;
animation.beginTime = 0; // ignore delay time for now
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
[p_view.layer addAnimation:animation forKey:@"horizontal_animation"];
}
现在我想添加一个滚动效果,一个在屏幕上滚动的2D足球
如何创建在每次迭代中调用的方法,以便旋转图像?
有更简单的方法吗?
您想将图像映射到球体表面,并使其在屏幕上旋转吗?这相当复杂。您需要使用OpenGL和纹理映射。您将创建一个近似球体作为点栅格,并将要显示的图像映射到要绘制到曲面上的纹理 我通过添加另一个旋转的Cabasicanization实现了我想要的,当两者以相同的持续时间一起工作时,这就是我想要的结果
CABasicAnimation* animation2 = [CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];//@"transform.rotation.z"];
animation2.fromValue = [NSNumber numberWithFloat:0.0f];
animation2.toValue = [NSNumber numberWithFloat: 2*M_PI];
animation2.duration = 3;
animation2.repeatCount = 0.5;//INFINITY;
[p_view.layer addAnimation:animation2 forKey:@"SpinAnimation"];