0

I have a UIView that contains some labels and other data with the gif image.I want to capture that view as an image in a way that my gif animation remains intact in captured image

coffee
  • 498
  • 2
  • 6
  • 17

1 Answers1

1

I think below code will help you to capture your entire view and return as uiimage :

   -(UIImage*)captureView:(UIView*)myView
    {
        UIImage *screengrab;
        UIGraphicsBeginImageContextWithOptions(myView.bounds.size, myView.opaque, 0.0);
        [myView.layer renderInContext:UIGraphicsGetCurrentContext()];
        screengrab = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        return screengrab;
    }
nikdange_me
  • 2,949
  • 2
  • 16
  • 24
  • I have tried this method and it captures the view layer as image but i want to keep gif(which is added as subview in view) animated after capturing the view as image or anything else to obtain this functionality – coffee Mar 06 '17 at 12:14
  • do you mean that captured image i.e. "screengrab" image need to have 'animating' action gif image in it?? – nikdange_me Mar 06 '17 at 12:28
  • Yes,the captured image(screengrab) need to have 'animating' gif image in it.I really appreciate your help.Thanks – coffee Mar 06 '17 at 12:52
  • bro.. i doubt this !! it may be possible !? there won't be simple answer. – nikdange_me Mar 06 '17 at 12:58
  • I have tried this method and it captures the view layer as image but i want to keep gif(which is added as subview in view) animated after capturing the view as image or anything else to obtain this functionality @Ashish Shah – coffee Mar 06 '17 at 15:36