Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

printz

macrumors regular
Original poster
Dec 23, 2012
218
0
Is it possible to implement this effect in iOS? Make a view zoom in until it fills the whole screen, while the containing view slides to the left.
 
Is it possible to implement this effect in iOS? Make a view zoom in until it fills the whole screen, while the containing view slides to the left.

Yes, it should be fairly simple using UIView animation.

You will probably need to add a container view for everything that you want to slide left, and put your view that you want to zoom to fill the screen outside of that container view, so the expanding view doesn't shift left with everything else.

Then you'd use code something like this:

Code:
[UIView animateWithDuration: .2 
  animations: 
  ^{
      #if K_ANIMATE_FRAME
        //Note that changing the frame will only work if the view redraws itself at the 
        //new size. UIImageView can be set up that way, 
        //but other view types may not.
        viewToExpand.frame = containerView.frame;  
      #else
        //An alternate approach is to apply a scale to the view's transform:
        CGFloat scale = containerView.frame.size.width / 
          viewToExpand.frame.frame.size.width;
        viewToExpand.transform = CGAffineTransformMakeScale(scale, scale);
      #endif
      //Now animate the container view off-screen
      CGPoint center = containerView.center;
      //Shift the container view left.
      center.x -= containerView.bounds.size.width; 
      containerView.center = center;
  }
];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.