0

I have a page in my app in which there is user's profile pic in a circle as its there in Twitter profile page.

I have to add a functionality such that when I tap on it, the image should expand. Animation needs to be added in such a way that a new bigger circle should slowly appear from the centre of the smaller circle and reach the centre of the screen.

Any ideas as to how this can be implemented?

Kavita Kanwar
  • 285
  • 3
  • 12

3 Answers3

0

Try UIView Animation block with changing bigger circle's position, size, alpha, and corner radius (if required).

Place your bigger circle (with smaller size initially) on top of smaller circle and hide it initially. Then before animation, un-hide it and animate using a block like this:

[UIView animateWithDuration:1.0 animations:^{
        // set bigger circle destination position i.e. centre of screen
        // set bigger circle final size
        // set other properties like alpha, corner radius etc
    } completion:nil];
Maverick
  • 3,209
  • 1
  • 34
  • 40
0

Use CATransform3DScale transform and UIView Animation

CATransform3D avatarTransform = CATransform3DIdentity;
avatarTransform = CATransform3DScale(avatarTransform, avatarScaleFactor,avatarScaleFactor, 0);


[UIView animateWithDuration:1.0 animations:^{
    //Change the frame to reach the center of screen
    self.avatar.layer.transform = headerTransform
} completion:nil]
Mukesh
  • 3,680
  • 1
  • 15
  • 32
0

You can simply use CGAffineTransformScale and scale your ImageView inside UIView's animateWithDuration block.

imgV.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.0, 0.0);

[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseInOut
                 animations:^{
                     imgV.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.0);

                 }
                 completion:^(BOOL finished) {
                    NSLog(@"done");
                 }];

For further references you can look into these Stackoverflow questions :

  1. Animate a UIImageView
  2. iOS View Transform Animation
Community
  • 1
  • 1
Munahil
  • 2,381
  • 1
  • 14
  • 24