开发人员有了这个三方框架,再也不用去苦恼各种动画的实现了,还得跟UI设计人员扯皮。
框架的优点:
UI设计人员将动画图制作好了后,利用工具转为json文件,开发人员通过框架提供的方法加载json就可以实现各种精彩的动画。
缺点:
这个框架的动画效果只能作为展示,不能产生交互行为。
通过cocoapods集成。例如: pod 'lottie-ios', '~> 2.5.0'
Lottie支持iOS 8 及其以上系统。当我们把动画需要的images资源文件添加到Xcode的目标工程的后,Lottie 就可以通过JSON文件或者包含了JSON文件的URL来加载动画。
JSON示例如下:
{"assets":[{"id":"image_0","w":383,"h":261,"u":"images/","p":"img_0.png"},{"id":"image_1","w":383,"h":245,"u":"images/","p":"img_1.png"},{"id":"image_2","w":383,"h":245,"u":"images/","p":"img_2.png"},{"id":"image_3","w":383,"h":245,"u":"images/","p":"img_3.png"},{"id":"image_4","w":383,"h":382,"u":"images/","p":"img_4.png"},{"id":"image_5","w":440,"h":440,"u":"images/","p":"img_5.png"}],"layers":[{"ddd":0,"ind":0,"ty":2,"nm":"高光/水流动效2.psd","cl":"psd","refId":"image_0","ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[220.75,160.625,0]},"a":{"k":[191.5,130.5,0]},"s":{"k":[100,100,100]}},"ao":0,"ip":0,"op":58,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":2,"ty":2,"nm":"椭圆 1 拷贝 7","td":1,"refId":"image_1","ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[221.5,289.5,0]},"a":{"k":[191.5,122.5,0]},"s":{"k":[100,100,100]}},"ao":0,"hasMask":true,"masksProperties":[{"inv":false,"mode":"n","pt":{"k":{"i":[[0,0],[0,-18.605],[105.271,0],[0,105.15],[-4.957,16.959]],"o":[[4.981,16.996],[0,105.15],[-105.271,0],[0,-18.559],[0,0]],"v":[[374.441,0.371],[382.094,53.953],[191.484,244.344],[0.875,53.953],[8.491,0.497]],"c":true}},"o":{"k":100},"x":{"k":0},"nm":"蒙版 1"}],"ip":0,"op":58,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":3,"ty":4,"nm":"形状图层 1","tt":1,"ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":0,"s":[220,220,0],"e":[-278,218,0],"to":[-83,-0.33333334326744,0],"ti":[83,0.33333334326744,0]},{"t":57}]},"a":{"k":[0,0,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[54,-1],[40.045,0.646],[47,-25],[84,57],[13,-28],[0,0],[0,0],[41,101],[46,-3],[67,4]],"o":[[-77.781,1.44],[-62,-1],[-25.282,13.448],[-84,-57],[-13,28],[0,0],[0,0],[-41,-101],[-47.784,3.116],[-50.13,-2.993]],"v":[[324,-27],[172,13],[2,-34],[-134,-16],[-301,39],[-303,220],[609,218],[767,135],[622,-20],[468,38]],"c":true}},"nm":"路径 1","mn":"ADBE Vector Shape - Group"},{"ty":"fl","c":{"k":[1,1,1,1]},"o":{"k":100},"nm":"填充 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"k":[77,0],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"变换"}],"nm":"形状 1","np":3,"mn":"ADBE Vector Group"}],"ip":0,"op":58,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":4,"ty":2,"nm":"椭圆 1 拷贝 8","td":1,"refId":"image_2","ks":{"o":{"k":25.098},"r":{"k":0},"p":{"k":[221.5,289.5,0]},"a":{"k":[191.5,122.5,0]},"s":{"k":[100,100,100]}},"ao":0,"hasMask":true,"masksProperties":[{"inv":false,"mode":"n","pt":{"k":{"i":[[0,0],[0,-18.605],[105.271,0],[0,105.15],[-4.957,16.959]],"o":[[4.981,16.996],[0,105.15],[-105.271,0],[0,-18.559],[0,0]],"v":[[374.441,0.371],[382.094,53.953],[191.484,244.344],[0.875,53.953],[8.491,0.497]],"c":true}},"o":{"k":100},"x":{"k":0},"nm":"蒙版 1"}],"ip":0,"op":58,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":5,"ty":4,"nm":"形状图层 2","tt":1,"ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":0,"s":[16,221,0],"e":[220,220,0],"to":[34,-0.16666667163372,0],"ti":[-34,0.16666667163372,0]},{"t":57}]},"a":{"k":[0,0,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[46,2],[0,0],[0,0],[0,0],[0,0],[187,3],[40,-1],[38.053,0],[51,1],[42.059,0]],"o":[[-52.296,-2.274],[0,0],[0,0],[0,0],[0,0],[-33.611,-0.539],[-48.995,1.225],[-48,0],[-46.035,-0.903],[-36,0]],"v":[[-116,-39],[-191,1],[-248,33],[-247,221],[652,218],[400,34],[307,-39],[203,19],[90,-40],[-20,19]],"c":true}},"nm":"路径 1","mn":"ADBE Vector Shape - Group"},{"ty":"fl","c":{"k":[1,1,1,1]},"o":{"k":100},"nm":"填充 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"k":[0,0],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"变换"}],"nm":"形状 1","np":3,"mn":"ADBE Vector Group"}],"ip":0,"op":58,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":6,"ty":2,"nm":"椭圆 1 拷贝 9","td":1,"refId":"image_3","ks":{"o":{"k":14.902},"r":{"k":0},"p":{"k":[221.5,289.5,0]},"a":{"k":[191.5,122.5,0]},"s":{"k":[100,100,100]}},"ao":0,"hasMask":true,"masksProperties":[{"inv":false,"mode":"n","pt":{"k":{"i":[[0,0],[0,-18.605],[105.271,0],[0,105.15],[-4.957,16.959]],"o":[[4.981,16.996],[0,105.15],[-105.271,0],[0,-18.559],[0,0]],"v":[[374.441,0.371],[382.094,53.953],[191.484,244.344],[0.875,53.953],[8.491,0.497]],"c":true}},"o":{"k":100},"x":{"k":0},"nm":"蒙版 1"}],"ip":0,"op":58,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":7,"ty":4,"nm":"形状图层 3","tt":1,"ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":11,"s":[220,220,0],"e":[-349,234,0],"to":[-94.8333358764648,2.33333325386047,0],"ti":[94.8333358764648,-2.33333325386047,0]},{"t":57}]},"a":{"k":[0,0,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[69,-19],[71,57],[63,-79],[69.001,85],[82,-9],[67,25],[53,0],[89.782,76.787],[30,-30],[0,0],[0,0],[0,0]],"o":[[-69,19],[-79.221,-63.6],[-74.884,93.901],[-137.828,-169.789],[-82,9],[-67,-25],[-53,0],[-76,-65],[-30,30],[0,0],[0,0],[0,0]],"v":[[891,-46],[673,68],[509,-26],[339,27],[106,54],[-43,-42],[-208,52],[-344,-20],[-532,35],[-588,292],[1064,292],[1064,93]],"c":true}},"nm":"路径 1","mn":"ADBE Vector Shape - Group"},{"ty":"fl","c":{"k":[1,1,1,1]},"o":{"k":100},"nm":"填充 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"k":[0,0],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"变换"}],"nm":"形状 1","np":3,"mn":"ADBE Vector Group"}],"ip":0,"op":58,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":8,"ty":2,"nm":"椭圆 1 拷贝 6","refId":"image_4","ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[221.5,221,0]},"a":{"k":[191.5,191,0]},"s":{"k":[100,100,100]}},"ao":0,"hasMask":true,"masksProperties":[{"inv":false,"mode":"n","pt":{"k":{"i":[[-105.271,0],[0,-105.15],[105.271,0],[0,105.15]],"o":[[105.271,0],[0,105.15],[-105.271,0],[0,-105.15]],"v":[[191.484,0.563],[382.094,190.953],[191.484,381.344],[0.875,190.953]],"c":true}},"o":{"k":100},"x":{"k":0},"nm":"蒙版 1"}],"ip":0,"op":58,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":9,"ty":2,"nm":"透明圆","refId":"image_5","ks":{"o":{"k":14.902},"r":{"k":0},"p":{"k":[221,221,0]},"a":{"k":[220,220,0]},"s":{"k":[100,100,100]}},"ao":0,"ip":0,"op":58,"st":0,"bm":0,"sr":1}],"v":"4.5.4","ddd":0,"ip":0,"op":58,"fr":29,"w":440,"h":440}
调用方式:
至于图片从哪里来?找设计,谁给你提供动画JSON文件,就找谁。
效果如下图,这里没截视频,因此是静态的,动手操作,就会看到是动态的。
网友评论