Finally, I found what I need: instead of assigning images to the selected and unselected states of my button, I keep my button transparent and add two views to this button instead, first with alpha 1.0 and 0.0.
When the button is selected and I enter the method specified in the selector, I use the animation to switch between the two views as follows:
NSArray * subviewArray = [button subviews]; [UIView animateWithDuration:2.0 animations:^ { ((UIView *)[subviewArray objectAtIndex:0]).alpha = 0.0; ((UIView *)[subviewArray objectAtIndex:1]).alpha = 1.0; } completion:nil];
This approach also works if the button moves during the transition. Hope this helps others who face the same issue in the future!
source share