Objective c 如何在设置图像动画时拍摄UIImageView的屏幕截图
我试图捕捉屏幕,当它在图像视图中只有一个图像时,它工作得非常完美……但是当我为UIImageView设置动画时,我得到的是一个空白的屏幕截图Objective c 如何在设置图像动画时拍摄UIImageView的屏幕截图,objective-c,uiimageview,uiimage,Objective C,Uiimageview,Uiimage,我试图捕捉屏幕,当它在图像视图中只有一个图像时,它工作得非常完美……但是当我为UIImageView设置动画时,我得到的是一个空白的屏幕截图 CGRect rect = [self.view bounds]; UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); [self.view.layer renderInContext:context];
CGRect rect = [self.view bounds];
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[self.view.layer renderInContext:context];
UIImage *capturedScreen = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(capturedScreen, nil, nil, nil);
我不知道我的答案是对还是错,但我试着这样做。。。 多亏了
-(无效)更改
{
如果(i>=imags.count-1)
i=0;
其他的
i++;
}
-(空)图像
{
NSArray*imagenames=@[@“1.png”、@“b.png”、@“c.png”];
int j;
NSMutableArray*图像=[[NSMutableArray alloc]init];
对于(j=0;j
-(void)change
{
if (i>=imags.count-1)
i=0;
else
i++;
}
-(void)images
{
NSArray *imagenames = @[@"1.png",@"b.png",@"c.png"];
int j;
NSMutableArray *images= [[NSMutableArray alloc]init];
for (j=0; j<imagenames.count; j++)
[images addObject:[UIImage imageNamed:[imagenames objectAtIndex:j]]];
self.imageview1.animationImages = images;
self.imageview1.animationDuration =1;
[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(change) userInfo:nil repeats:YES];
[self.bground startAnimating];
}
-(IBAction)captureImage:(id)sender
{
self.imageview2.image = [images objectAtIndex:i];
CGRect rect = [self.view bounds];
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[self.view.layer renderInContext:context];
UIImage *capturedScreen = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(capturedScreen, nil, nil, nil);
}