So I’ve searched a lot but I didn’t find an answer for my problem.
I want to make a button that would have two images, first image that is when button is in normal state, the other one when it is in highlighting state. The problem is that i want these images to change in animated manner, for example the first image fades out, when the second fades in. And they change in such a way that the animation time remains constant.
The only way I thought is, to make a custom button, add couple of ImageViews and on button touch down event, one ImageView fades in, other fades out, on button touch up event, I could do the opposite. But this method doesn’t seem the most suitable. Is there a better option that I am not seeing?
I’ve done it the following way, similarly as Ilker Baltaci has described it:
I subclassed UIButton (although it’s not advised because it’s a class cluster) and added a function to it:
a lot of block-animation cascades, ugly i know!
But anyway, you can adapt the animation block to your needs and exclude the delegate callback.
then in your IBAction/target-action method for the button press just call the method, like: