UIImageView scale from center using Animation Blocks

前端 未结 3 1487
被撕碎了的回忆
被撕碎了的回忆 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: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.

提交回复
热议问题