Reputation: 91
I'm building a scene with Core Animation which looks similar to the screensaver on the old Apple TV. A continuous stream of images (each a CALayer
) passes by vertically, from the bottom to top. To achieve this, after a layer’s animation ends when it moves out of view, it is repositioned back to the bottom, assigned a new image, and reanimated. This takes place in the animationDidStop
delegate method. However, I’ve noticed that if I take a screenshot when running the app on an iPad, the layers are never repositioned to the bottom, and aren’t seen again. I've isolated the problem, and I'm certain that taking screenshots is causing it. This leads me to think that taking a screenshot has an effect on animation timing. So...
Upvotes: 9
Views: 1152
Reputation: 55
You could always try capturing the screenshot programmatically based upon the contents of the view, then save it as a screenshot. I do not know your objects, but this is what I have done before. All of my content for the screenshot is in CaptureView.
CGRect screenRect = [[UIScreen mainScreen] bounds];
UIGraphicsBeginImageContext(CaptureView.frame.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[[UIColor clearColor] set];
CGContextFillRect(ctx, screenRect);
[CaptureView.layer renderInContext:ctx];
UIImage *screenImage = UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(screenImage, nil, nil, nil);
UIGraphicsEndImageContext();
Is your animation in a stationary UIImageView
? If it is the image view that you want to detect going off of the screen, just use it's frame.origin.y
compared to 0.
Upvotes: 1
Reputation: 425
You can use presentationLayer to capture screenshot while you animation is animating.
i.e. [CaptureView.layer presentationLayer]
you can also detect touch while animating in presentationLayer of the CALayer
.
Upvotes: 0