OSX Fullscreen-like animation effect?

Discussion in 'iOS Programming' started by printz, Oct 16, 2013.

  1. printz macrumors regular

    Joined:
    Dec 23, 2012
    #1
    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.
     
  2. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #2
    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;
      }
    ];
     

Share This Page