Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何在设置图像动画时拍摄UIImageView的屏幕截图_Objective C_Uiimageview_Uiimage - Fatal编程技术网

Objective c 如何在设置图像动画时拍摄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];

我试图捕捉屏幕,当它在图像视图中只有一个图像时,它工作得非常完美……但是当我为UIImageView设置动画时,我得到的是一个空白的屏幕截图

  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);


      }