M
M
Max Onflic2015-09-20 23:17:19
iOS
Max Onflic, 2015-09-20 23:17:19

How to attach animation to custom button?

habrahabr.ru/post/258107 - From this article, I wanted to make a custom solution by hiding the animation under the hood. After moving the code to the custom button class, the animation does not work either in the -drawRect method or in -laoutSubview. There are solutions where to push the execution so that the animation works out?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
An, 2015-09-21
@Flanker_4

It all depends on what you want to do and how.
It is possible to add this animation at the moment of setting the image on the button (setImage:forState:/setBackgroundInage:forState)
or at the moment of adding the view to the "scene"
didMoveToSuperview
Animation should definitely not be added to drawRect. laoutSubview there
There is another option to create a separate method (animateMe) and pull it when necessary

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question