分享一个商城添加到购物车的2种动画(组合动画和贝塞尔曲线动画)
github地址:https://github.com/yellowwing/ShoppingCarAnimation
先说第一种的组合动画,点击立即购买后,商品的图片会从cell的位置一边选择一边缩小一边移动到“我的”的位置,然后“我的”的item的badge会加1
先看效果图




这里的运动轨迹是直线的,代码先不说,具体去github下载我分享的demo看,这里主要说下面的贝塞尔曲线的运动轨迹
先看效果图:




它的运动轨迹是曲线的,并且会慢慢缩小,这是用到贝塞尔曲线和帧动画,再组合动画完成。
主要代码如下:

然后是创建贝塞尔曲线:



具体看github地址:https://github.com/yellowwing/ShoppingCarAnimation
网友评论