I’m trying to animate a custom UIButton but my code doesn’t seems to work. I’m using this in ViewDidLoad:
[UIView animateWithDuration:40.0 delay:0 options:UIViewAnimationOptionRepeat animations:^{
duckButton.frame = CGRectMake(120, 80, 120, 180);
duckButton.frame = CGRectMake(200, 90, 120, 180);
} completion:^(BOOL finished) {
}];
What should I do?
[Edit: The answer is on the comments]
I’m bringing out what I said in the comments to make it as an actual answer as suggested by BoltClock.
I want to point out that there really is no issue with the code (except that the frame is set for two different final locations). The issue is that the button was not properly initialized prior to execution of the animation block, and since a nil object can not have a frame it essentially did nothing.