Axis in animation

Discussion in 'iOS Programming' started by AguaRas, Nov 27, 2012.

  1. AguaRas macrumors newbie

    Joined:
    Nov 27, 2012
    #1
    Hello.
    This developing an application that makes an animation of a view in the x-axis of 320, so that it appears to the right.

    Code:
     [self.view setTransform:CGAffineTransformMakeTranslation(320, 0)];
    
    The problem I have is when the iPhone is in portrait and the animation comes from the bottom, rather than the right.

    What I can do to make it always right?
     
  2. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    Why not just do a UIView animation block where you set it's frame +320 pixels?
     
  3. AguaRas thread starter macrumors newbie

    Joined:
    Nov 27, 2012
  4. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #4
    Code:
             [UIView animateWithDuration:0.3 animations:^{
                [currentLayer setFrame:CGRectMake(350, currentLayer.frame.origin.y, CGRectGetWidth(currentLayer.frame), CGRectGetHeight(currentLayer.frame))];
            }];
    Something like that; you can play with the frame you give it, it expects, X/Y, WIDTH/HEIGHT as parameters :)
     

Share This Page