0

I have a UIView with a button which on tapping displays a dropDownList which fills half the screen. I'm taking a screenshot of the sameView(before tapping the button) and using it as a blur background. My problem is screenshot is taken after the button is tapped but i wanted it to be taken before the button tapped(Initial screen).

i've tried the following code

    -(void)ViewDidLoad
          {
              [self imageWithView:self.view];
              [self blurScreenshot];
           }

   - (UIImage *) imageWithView:(UIView *)view
       {
      UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque,[[UIScreen mainScreen] scale]);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
 return img;
}


 -(void)blurScreenshot
{
UIImage *pngImg = [self imageWithView:self.view];
   screenshot = [[UIImageView alloc]initWithFrame:CGRectMake(0,200,self.view.frame.size.width,self.view.frame.size.height-200)];

UIColor *tintColor =[UIColor colorWithWhite:1.0 alpha:0.2];
UIImage * bluredImage = [pngImg applyBlurWithRadius:2 tintColor:tintColor saturationDeltaFactor:1.5 maskImage:nil ];

screenshot.image = bluredImage;

}

- (IBAction)OnClickingIndicator:(id)sender {
    ++x;
   NSLog(@"log value%d",x);
   [self.childViewControllers[0] view].hidden = ! [self.childViewControllers[0] view].hidden;
if(x % 2 == 0)
{
    [self.view addSubview:screenshot];
    [self.view bringSubviewToFront:screenshot];

   }else
    {
    [screenshot removeFromSuperview];

    [ blurEffectView removeFromSuperview];
  }  
}

My screen is similar to this only change is before TimeLine is clicked screenshot must be taken and blured so that it is used as a background when the TimeLine is tapped.

enter image description here

gowtham
  • 73
  • 1
  • 11

0 Answers0