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

gwelmarten

macrumors 6502
Original poster
Jan 17, 2011
476
0
England!
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
 
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) {
                         
                     }
     ];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.