I followed the instructions here to capture screenshots during animation (I am trying to record UIView with an animated label to capture it as video)
here is my code for screen capture in my ViewController (getframe)
-(UIImage*) getCurrentFrame {
UIGraphicsBeginImageContext(self.view.bounds.size);
CGContextRef mycontext = UIGraphicsGetCurrentContext();
[[[self.view layer] presentationLayer] renderInContext:mycontext];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
when I try to make a video of the screenshots, I repeatedly see only the start frame - as my thread (using AVAssetwriter example) grabs subsequent screenshots nothing in the screengrab moves. the screengrab is called during AVAssetWriterInput usingblock in a while loop.
My animation is a simple core animation on a label - scroll down example
mTextLabel.frame = CGRectMake(mTextLabel.frame.origin.x,
-100,
mTextLabel.frame.size.width,
mTextLabel.frame.size.height);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration: delay];
[UIView setAnimationTransition:UIViewAnimationTransitionNone
forView:mTextLabel cache:YES];
mTextLabel.frame = CGRectMake(mTextLabel.frame.origin.x,
240,
mTextLabel.frame.size.width,
mTextLabel.frame.size.height);
[UIView commitAnimations];
I tried replacing the old school animation with the block animation animatewithDuration but get the same results
Any suggestions? Using ios 6 and latest xcode (have imported Quartzcore correctly)
Apple dev center said that somethings might not be captured.
Is another option to stage the animation with timers and intermittently grab screens (will have to handcode animations)?
EDIT - Hooray ! Apple finally added this -
[view drawViewHierarchyInRect:self.view.bounds afterScreenUpdates:NO];
wrap between Begin and End Graphics Context calls !
------------ pre iOS7 --------------- From Apple's Documentation for CALayer here! In renderInContext they clearly say
"Important: The OS X v10.5 implementation of this method does not support the entire Core Animation composition model. QCCompositionLayer, CAOpenGLLayer, and QTMovieLayer layers are not rendered. Additionally, layers that use 3D transforms are not rendered, nor are layers that specify backgroundFilters, filters, compositingFilter, or a mask values. Future versions of OS X may add support for rendering these layers and properties."
The only option for me is to use server side solution OR handcode the animation frame by frame by manually overlaying the transformation at time t.