2
我有一個imageview,它每隔幾秒就會改變一次curl動畫。我想拍攝這樣的視頻,因此我正在做的是,我每秒鐘都會截取屏幕截圖並從中創建視頻。 但是,當圖像動畫時,我無法拍攝屏幕截圖,那時它將返回圖像穩定或不具有動畫效果的屏幕截圖。動畫圖像的屏幕截圖
我使用下面的代碼把圖像的截圖
{
CGSize imageSize = [[UIScreen mainScreen] bounds].size;
if (NULL != UIGraphicsBeginImageContextWithOptions)
UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0);
else
UIGraphicsBeginImageContext(imageSize);
CGContextRef context = UIGraphicsGetCurrentContext();
// Iterate over every window from back to front
for (UIWindow *window in [[UIApplication sharedApplication] windows])
{
if (![window respondsToSelector:@selector(screen)] || [window screen] == [UIScreen mainScreen])
{
// -renderInContext: renders in the coordinate space of the layer,
// so we must first apply the layer's geometry to the graphics context
CGContextSaveGState(context);
// Center the context around the window's anchor point
CGContextTranslateCTM(context, [window center].x, [window center].y);
// Apply the window's transform about the anchor point
CGContextConcatCTM(context, [window transform]);
// Offset by the portion of the bounds left of and above the anchor point
CGContextTranslateCTM(context,
-[window bounds].size.width * [[window layer] anchorPoint].x,
-[window bounds].size.height * [[window layer] anchorPoint].y);
// Render the layer hierarchy to the current context
[[[window layer] presentationLayer] renderInContext:context];
// Restore the context
CGContextRestoreGState(context);
}
}
// Retrieve the screenshot image
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
沒有任何一個有關於它的主意?
在此先感謝。
-Austin
儘量減少截屏之間的時期東西少 –
是已經試過.. – Austin
什麼區間,美試過嗎? –