UIImageView scale from center using Animation Blocks

前端 未结 3 1398
被撕碎了的回忆
被撕碎了的回忆 2021-02-08 01:31

I am using the following to scale image up but it\'s scaling from it\'s left top point, how can I make the scale from center

[UIView animateWithDuration:duration         


        
相关标签:
3条回答
  • 2021-02-08 01:51
    [UIView animateWithDuration:0.5 
                          delay:0
                        options:UIViewAnimationOptionBeginFromCurrentState
                     animations:(void (^)(void)) ^{
                         myImageView.transform=CGAffineTransformMakeScale(1.2, 1.2);
                     }
                     completion:^(BOOL finished){
                         myImageView.transform=CGAffineTransformIdentity;
                     }];
    

    this will work perfectly
    Good Luck

    0 讨论(0)
  • 2021-02-08 01:59

    Try this:

    [UIView animateWithDuration:2
       animations:^{
           float zoomScal = 5; //want 5x zoom
           CGPoint CenterPoint = CGPointMake(200, 300); // want center point to this
           imgArtifactImage.frame = CGRectMake(- CenterPoint.x * (zoomScal-1),- CenterPoint.y * (zoomScal-1),self.view.frame.size.width * zoomScal,self.view.frame.size.height * zoomScal);
    } completion:^(BOOL finished){}];
    

    It's working for me.

    0 讨论(0)
  • 2021-02-08 02:13

    this can be the block of animation for the scale up the image

    here as theView U Can Use the uiimageview

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:GROW_ANIMATION_DURATION_SECONDS];
    theView.transform = CGAffineTransformMakeScale(1.2, 1.2);
    
    [UIView commitAnimations];
    
    0 讨论(0)
提交回复
热议问题