Animating UIButton whilst not disabling interaction

Discussion in 'iOS Programming' started by gwelmarten, Mar 25, 2013.

  1. gwelmarten macrumors 6502

    Joined:
    Jan 17, 2011
    Location:
    England!
    #1
    Lots of posts have been written about UIView animation with code such as:
    Code:
    [UIView animateWithDuration:5.2
                              delay: 0
                            options: UIViewAnimationOptionAllowUserInteraction
                         animations:^{
                             tapButton.frame = CGRectMake(230, 470, 78, 130);
                         }
                         completion:^(BOOL completed) {
                             // completion logic
                         }
         ];
    where people want the button to still be clickable whilst been animated, and people have given hints. But with the above code, my button moves from the top of the screen to the bottom and is not clickable in the middle, i.e. when it is moving. So I can't click it when it is moving.

    How do I do this? Can someone give a precise pointer to a reference or some sample code? I did read CoreAnimation might be useful, but I read the docs and couldn't see it.

    Thanks
     
  2. gwelmarten thread starter macrumors 6502

    Joined:
    Jan 17, 2011
    Location:
    England!
    #2
    Answer:

    After another few hours, found I could do it like this after importing QuartzCore:

    Code:
    -(void)animateDroplet {
        tapButton.frame = originalDropletPosition;
        
        [UIView animateWithDuration:3
                              delay: 0
                            options: UIViewAnimationOptionCurveEaseIn | UIViewAnimationOptionAllowUserInteraction
                         animations:^{
                             tapButton.frame = finalDropletPosition;
                         }
                         completion:^(BOOL completed) {
                             
                         }
         ];
     

Share This Page