Airbnb的開源專案Lottie簡易實現動畫

2021-07-26 13:49:37 字數 1755 閱讀 6438

lottie是airbnb最近推出的開源專案,設計師只要使用ae把動畫做出來,再使用bodymovin外掛程式就能把動畫檔案匯出成json檔案。這個json檔案中包括動畫的點的座標,執行的軌跡等資料,在專案中引用這個開源庫,使用這個json檔案(或者url)就可以實現動畫,極快的完成了乙個動畫效果,要知道,簡單的乙個動畫,用**實現起來都需要花一定的時間。

這個庫是跨平台的,只要設計出一套json動畫描述檔案,就可以支援android,ios,reactnative,ios目前是支援ios8及以上的,同時支援oc和swift,下面講ios的用法。

pod 'lottie-ios'

pod install

github "airbnb/lottie-ios"

"master"

carthage update

載入json本地檔案

//載入本地的json描述檔案

laanimationview *animation = [laanimationview animationnamed:@"lottie"];

[self

.view addsubview:animation];

animation.loopanimation = yes;

//1.直接開啟

[animation playwithcompletion:^(bool animationfinished) ];

//2.手動開啟

//設定動畫的進度

= 0//[animation play]

//手動關閉

//[animation pause]

載入url

laanimationview *animation = [[laanimationview alloc] initwithcontentsofurl:[nsurl urlwithstring:url]];

[self

.view addsubview:animation];

#pragma mark -- view controller transitioning

\\- (id

)animationcontrollerforpresentedcontroller:(uiviewcontroller *)presented

presentingcontroller:(uiviewcontroller *)presenting

sourcecontroller:(uiviewcontroller *)source

\\- (id

)animationcontrollerfordismissedcontroller:(uiviewcontroller *)dismissed

let animationview = laanimationview.animationnamed("hamburger")

self.view

.addsubview(animationview!)

animationview?.play(completion: )

這個專案碉堡了

airbnb/lottie-ios

C 開源專案

1.emule 2.todolist 3.ftpserver 4.wxwidgets 5.tightvnc 6.codejock.xtreme.suite.pro.activex 7.jrtplib 8.boost 9.nopepad 10.opencv 11.qt,gtk 12.openoffic...

docker docker開源專案

最早接觸docker是在14年年初,當初docker遠沒有這在這麼火,當時覺得docker也就是類似openstack cloudstack的乙個容器管理,沒什麼特別,沒想到啊,半年的時間裡,發生了如此翻天覆地的變化 vmware與docker合作 rhel 7整合docker cloudfoudr...

docker fig開源專案

今日主題 docker之fig開源專案。serf image ctlc serf ports 7373 7946 lb image ctlc haproxy ports 80 80 links serf environment haproxy password qa1n76pwari9 web im...