Implementation method of swift shuffle animation effect

Objective effect: after clicking the animation button, each card rotates and spreads to any position in the upper half of the screen, and then returns to the initial position, which is more like the skill animation of lol men's knife:)

1: Create a card object

Create each card as uiimageview. In order to operate these cards later, I use the array to create them in the same location. After that, I use the local notification to send a setcreated message to tell the observer of this page that the card set has been created and can start the second animation

2: First, you need to turn off the user interaction of the button to start animation. If it is on, continuous clicking will create 50 cards each time, causing the program to get stuck or even hang up

The delaytime here is to add a delay time to the thread, just to make the animation less stiff

Every time I cycle, I add rotation animation to the card object corresponding to the subscript and change its origin. Before I use uiview animation to realize this set of animation, I want to add Bezier curve to each card, which is indeed more controllable. However, due to time, I only use uiviewanimation, and the rotation animation added to the card is realized by pop animation library, Basic animation is used here After this step, each card will be rotated and scattered to different positions. When the delaytime ends and triggers the local notification to send shufflefinished, the observer on this page will execute the next animation, that is, restore each card to the starting point of the animation

3: Restore the of each card to its original position, and set the title of the button to the card cutting state

After the card washing, the demand is to cut the card. Due to time reasons, we will continue to update the follow-up animation effect next week

The above is the implementation method of swift shuffle animation effect introduced by Xiaobian. I hope it will help you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>