I want to animate a view by centering one of its points to the center of the screen and then scale it up.

So, if I have this screen (

S

) with a view (

V

) in it, and a certain point (

x

):

+-------------+ |S-----------+| ||V || || || || || || || || || || x || || || |+-----------+| +-------------+I want it to animate to this position:

+-----------+ +---V---------+| |S | || | | || | | || | | || | | x || | | || | +----------|+ | | | | +-------------+where the point is centered in the screen, and then scale it like this:

+-------------------+ |V | | | | | | | |+-------------+ | ||S | | || | | || | | || | | || x | | || | | || | | || | | || | | |+-------------+ | +-------------------+however, I cant accomplish this, even using

CGAffineTransformConcat, which I though is it designed exactly for cases like this.

I have tried this:

CGAffineTransform translateTransform = CGAffineTransformMakeTranslation(deltaPoint.x, deltaPoint.y); CGAffineTransform scaleTransform = CGEqualAffineTransformMakeScale(40); self.screenView.transform = CGAffineTransformConcat(translateTransform, scaleTransform);where

deltaPointis a

CGPointhaving its

xand

yequal to the distance between the points absolute coordinates (relative to the screen) and the coordinates of the center of the screen, but it animates the point slightly to the right.

I also tried calculating the

deltaPointafter scaling to no avail:

self.screenView.transform = CGEqualAffineTransformMakeScale(40); calculate deltaPoint self.screenView.transform = CGAffineTransformTranslate(self.screenView.transform, deltaPoint.x, deltaPoint.y);In both cases, if I comment out the scaling transform, the translation works, it moved it perfectly center, so the problem isnt in the

deltaPointcalculation.

View More Answer And Comment : Stackoverflow

## Top Answer 1

I suppose screenView is your view (V)

so you can try something like this:

UIView animateWithDuration:2 put translation duration here animations:^{ self.screenView.center = CGPointMake(self.screenView.center.x + deltaPoint.x, self.screenView.center.y + deltaPoint.y); } completion:^(BOOL finished) { UIView animateWithDuration:2 put scale duration here animations:^{ self.screenView.transform = CGAffineTransformMakeScale(1.1, 1.1); here the final size will be 110% } completion:nil; } ;If you want to do this at the same time so simply put the scale in the same block:

UIView animateWithDuration:2 put translation duration here animations:^{ self.screenView.center = CGPointMake(self.screenView.center.x + deltaPoint.x, self.screenView.center.y + deltaPoint.y); self.screenView.transform = CGAffineTransformMakeScale(1.1, 1.1); here the final size will be 110% } completion:nil ;

## Top Answer 2

I suppose screenView is your view (V)

so you can try something like this:

UIView animateWithDuration:2 put translation duration here animations:^{ self.screenView.center = CGPointMake(self.screenView.center.x + deltaPoint.x, self.screenView.center.y + deltaPoint.y); } completion:^(BOOL finished) { UIView animateWithDuration:2 put scale duration here animations:^{ self.screenView.transform = CGAffineTransformMakeScale(1.1, 1.1); here the final size will be 110% } completion:nil; } ;If you want to do this at the same time so simply put the scale in the same block:

UIView animateWithDuration:2 put translation duration here animations:^{ self.screenView.center = CGPointMake(self.screenView.center.x + deltaPoint.x, self.screenView.center.y + deltaPoint.y); self.screenView.transform = CGAffineTransformMakeScale(1.1, 1.1); here the final size will be 110% } completion:nil ;

## Top Answer 3

I suppose screenView is your view (V)

so you can try something like this:

UIView animateWithDuration:2 put translation duration here animations:^{ self.screenView.center = CGPointMake(self.screenView.center.x + deltaPoint.x, self.screenView.center.y + deltaPoint.y); } completion:^(BOOL finished) { UIView animateWithDuration:2 put scale duration here animations:^{ self.screenView.transform = CGAffineTransformMakeScale(1.1, 1.1); here the final size will be 110% } completion:nil; } ;If you want to do this at the same time so simply put the scale in the same block:

UIView animateWithDuration:2 put translation duration here animations:^{ self.screenView.center = CGPointMake(self.screenView.center.x + deltaPoint.x, self.screenView.center.y + deltaPoint.y); self.screenView.transform = CGAffineTransformMakeScale(1.1, 1.1); here the final size will be 110% } completion:nil ;

View More Answer And Comment : Stackoverflow