Search code examples
iphoneiosuiwebviewcalayercabasicanimation

Scaling webview animation


I have webview in a viewcontroller of size 50x50 (width and height). And I have button to scale/stretch the width and height of the webview. So whenever the button is pressed, I want to increase the height and width of the webview. I want to acheive this along with the animation. I have tried using the following code , but it is not working.

        CALayer* simple = [[CALayer alloc]init];
        simple = webView.layer;
        CATransform3D currentTransform = simple.transform;
        CATransform3D scaled = CATransform3DScale(currentTransform, 1.5, 1.5, 1.5);
        simple.transform = scaled;
        [simple setNeedsDisplay];

Please tell me how to scale a webview .


Solution

  • try this

    -(IBAction) incresethegeight:(id)sender
    {
    
    
    
        [UIView animateWithDuration:2 delay:1.0
                            options:UIViewAnimationOptionBeginFromCurrentState
                         animations:^{ self.view.alpha = 1; }
                         completion:^(BOOL fin){[self  addHeight ];}];
    }
    
    -(void) addHeight
    {  float height = webview.frame.size.height;
    
        CALayer* simple = [[CALayer alloc]init];
        simple = webview.layer;
        CATransform3D currentTransform = simple.transform;
        CATransform3D scaled = CATransform3DScale(currentTransform, 1.5, 1.5, 1.5);
        simple.transform = scaled;
        [simple setNeedsDisplay];
      // or  
    //   [webview setFrame:CGRectMake(0.0f, 0.0f, 320, height +30)];
    
    
    }