【发布时间】:2015-09-22 08:46:24
【问题描述】:
我有两张图片。第一个是像透明孔一样的东西,应该是静态的,而第二个是像滑板车一样的图像,需要不断水平滚动,应该会产生视频效果。
任何人都可以建议我做些什么来达到同样的效果。
【问题讨论】:
标签: ios iphone cocoa-touch
我有两张图片。第一个是像透明孔一样的东西,应该是静态的,而第二个是像滑板车一样的图像,需要不断水平滚动,应该会产生视频效果。
任何人都可以建议我做些什么来达到同样的效果。
【问题讨论】:
标签: ios iphone cocoa-touch
请查看代码Infinity Scroll
【讨论】:
您可以像这样为图像视图的 X 位置设置动画:
CGPoint point0 = imView.layer.position;
CGPoint point1 = { NSIntegerMax, point0.y };
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"position.x"];
anim.fromValue = @(point0.x);
anim.toValue = @(point1.x);
anim.duration = 1.5f;
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
// First we update the model layer's property.
imView.layer.position = point1;
// Now we attach the animation.
[imView.layer addAnimation:anim forKey:@"position.x"];
对于无限滚动,请正确设置您的滚动视图'contentSize:
scrollView.contentSize = CGSizeMake(NSIntegerMax, kScreenHeight); // Deduce kScreenHeight based on device height
【讨论】: