iOS 天氣動畫之多云(cloud)

效果圖

思詩

實現(xiàn)思路

多云(cloud)的動畫可以拆分成兩個部分:

  1. 飛鳥動畫

    • 飛鳥動畫,飛翔的動畫是一組幀動畫。共8張圖組成。
    • 在幀動畫的基礎上,增加了橫向移動的動畫(跟云飄動是一個原理)
    • 倒影的動畫跟上面的一樣,只是把透明度調(diào)成了0.4
  2. 云飄動

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
animation.toValue = toValue;
animation.duration = duration;
animation.autoreverses = autoreverses;
animation.removedOnCompletion = NO;
animation.repeatCount = MAXFLOAT;
animation.fillMode = kCAFillModeForwards;

Usage

1. import header
#import "WHWeatherView.h"
2. initialization
WHWeatherView *weatherView = [[WHWeatherView alloc] init];
self.weatherView.frame = self.view.bounds;
[self.view addSubview:self.weatherView];
3. show animation
typedef NS_ENUM(NSInteger, WHWeatherType){
    WHWeatherTypeSun = 0,
    WHWeatherTypeClound = 1,
    WHWeatherTypeRain = 2,
    WHWeatherTypeRainLighting = 3,
    WHWeatherTypeSnow = 4,
    WHWeatherTypeOther = 5
};
- (void)showWeatherAnimationWithType:(WHWeatherType)weatherType;

More

WHWeatherAnimation 目前有5種天氣 —— 晴天、陰天、雨天、雷陣雨、下雪。均已完工,接下來的一段時間,會陸續(xù)更新后面的實現(xiàn)方式。著急的小伙伴可以先去 Github。

動畫已經(jīng)運用在這個APP里,思詩 —— 思念詩歌,每日一詩。每天看天氣的同時,讀上一首好詩,豈不美哉!
若是感興趣,趕快去下載體驗吧,點擊上面鏈接或者App Store搜索“思詩”。

Github鏈接:

https://github.com/whbalzac/WHWeatherAnimation

思詩
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容