Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core Animation Screenshot on iPad

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...

  1. What impact does taking a screenshot on an iDevice have on animation?
  2. Is there a better way to achieve this effect?
like image 392
David Avatar asked Dec 26 '10 21:12

David


People also ask

Can you screen grab on iPad?

Do one of the following: On an iPad with a Home button: Simultaneously press and then release the top button and the Home button. On other iPad models: Simultaneously press and then release the top button (on the top-right edge of iPad) and either volume button.

Is there a snipping tool for iPad?

You can use Apple Pencil to quickly take a picture of the iPad screen, then mark it up to share with others or use in documents. To capture the screen, swipe up with Apple Pencil from either corner at the bottom of your iPad. To mark up the screenshot, draw with Apple Pencil.

How do you screenshot on an iPad Air 2022?

Take screenshot on your Apple iPad Air (2022) iPadOS 15.4Press the Top key. At the same time, press and hold the Top volume key and keep them both pressed to take a screenshot. To edit your screenshot, press the screenshot and follow the instructions on the screen to make the required changes.


1 Answers

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.

like image 179
cowbear16 Avatar answered Oct 13 '22 01:10

cowbear16