Note that there are some explanatory texts on larger screens.

plurals
  1. POCABasicAnimation - Infinite scrolling of an image on retina device is garbled
    primarykey
    data
    text
    <p>In a similar post, I found a solution to animating a scrolling image infinitely:</p> <p><a href="https://stackoverflow.com/questions/8790079/animate-infinite-scrolling-of-an-image-in-a-seamless-loop">Animate infinite scrolling of an image in a seamless loop</a></p> <p>While this solution works beautifully, there seems to be an issue when running on a retina device. In particular, I am running this project on an iPad only. A non-retina iPad 2 scrolls the image without any problems. But run on a retina iPad 3 or 4 the image is a mess! It's difficult to describe, but the best I can say is that it is garbled. Pixels are stretched every which way. It resembles a Jackson Pollak painting.</p> <p>Screen shot:</p> <p><a href="https://imgur.com/Q7n08kv" rel="nofollow noreferrer">http://imgur.com/Q7n08kv</a></p> <p>I tested this using a non-retina image (non 2x) and a retina version (@2x). The image is large - full screen (landscape) and is 4 panels wide (4096 x 768). I played around with smaller images but with the same result.</p> <p><strong>Is there a limitation with the scrolling functionality of CABasicAnimation that would affect retina devices?</strong> Here is the code I am using (as contributed by rob mayoff):</p> <pre><code>UIImage *crawlImage = [UIImage imageNamed:@"CrawlBackground.png"]; UIColor *crawlPattern = [UIColor colorWithPatternImage:crawlImage]; self.crawlLayer = [CALayer layer]; self.crawlLayer.backgroundColor = crawlPattern.CGColor; self.crawlLayer.transform = CATransform3DMakeScale(1, -1, 1); self.crawlLayer.anchorPoint = CGPointMake(0, 1); self.crawlLayer.frame = CGRectMake(0, 0, crawlImage.size.width + 1024, crawlImage.size.height); [self.backgroundCrawl.layer addSublayer:self.crawlLayer]; self.backgroundCrawl.layer.zPosition = 0; CGPoint startPoint = CGPointZero; CGPoint endPoint = CGPointMake(-crawlImage.size.width, 0); self.crawlLayerAnimation = [CABasicAnimation animationWithKeyPath:@"position"]; self.crawlLayerAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; self.crawlLayerAnimation.fromValue = [NSValue valueWithCGPoint:startPoint]; self.crawlLayerAnimation.toValue = [NSValue valueWithCGPoint:endPoint]; self.crawlLayerAnimation.repeatCount = HUGE_VALF; self.crawlLayerAnimation.duration = 30; // nn seconds to complete the cycle </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload