CGAffineTransformMakeTranslation position confusion

Discussion in 'iOS Development' started by cybohemia, Feb 15, 2009.

  1. cybohemia

    cybohemia New Member

    Jan 25, 2009
    Likes Received:
    iPhone 3G (Black)
    I want to move a view from the center-bottom up to center-center and then left to left-center.

    When I use CGAffineTransformMakeTranslation, it seems to start from wherever it needs to in order to end up at the upper left hand corner. I tried calling CGAffineTransformMakeTranslation before the animation to set it somewhere else but it seems to get ignored.

    I then tried setting the center of the view to something like (160,400).

    This helped: it began the animation at the right place but the problem then became when I started the second animation to move it to the left (I want to keep the beginAnimation's in separate blocks): it doesn't seem to know its current position and starts off wherever it needs to in order to end up at (160,400).

    I'm guessing I'm missing something fundamental about the transformations but I'm not sure what...

    Thanks for any help!
    ------------------double post merged------------------
    Ah - I figured it out.

    (If anyone is interested, I was assigning multiple transformations to the transform field. I should have concat'ed them first.)
  2. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Sep 19, 2007
    Likes Received:
    Translations aren't the recommended way to do what you want. What you should be doing is setting the animation delegate to self (or whatever other object) and setting the animationDidStop selector within the first animation block. When the animation is completed, the second selector is called. In that, set up the separate animation block.

    That said, there's nothing technically wrong with using your method.

Share This Page