美文网首页iOS开发攻城狮的集散地
iOS 天气动画之多云(cloud)

iOS 天气动画之多云(cloud)

作者: whbalzac | 来源:发表于2018-06-20 15:02 被阅读178次

效果图

思诗

实现思路

多云(cloud)的动画可以拆分成两个部分:

  1. 飞鸟动画

    • 飞鸟动画,飞翔的动画是一组帧动画。共8张图组成。
    • 在帧动画的基础上,增加了横向移动的动画(跟云飘动是一个原理)
    • 倒影的动画跟上面的一样,只是把透明度调成了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种天气 —— 晴天、阴天、雨天、雷阵雨、下雪。均已完工,接下来的一段时间,会陆续更新后面的实现方式。着急的小伙伴可以先去 Github

动画已经运用在这个APP里,思诗 —— 思念诗歌,每日一诗。每天看天气的同时,读上一首好诗,岂不美哉!
若是感兴趣,赶快去下载体验吧,点击上面链接或者App Store搜索“思诗”

Github链接:

https://github.com/whbalzac/WHWeatherAnimation

思诗

相关文章

网友评论

  • PGOne爱吃饺子:大佬 项目打不开啊 版本太高了
    whbalzac:@PGOne爱吃饺子 我下载试了下,没问题啊
    PGOne爱吃饺子:项目都打不开,设置不了啊
    whbalzac:@PGOne爱吃饺子 工程的设置是ios8以上, xcode9以上,你手动可以改低的。假如是ios版本过低,修改deployment target的版本;假如是xcode版本低了,修改storyboard的版本。改了就能跑过

本文标题:iOS 天气动画之多云(cloud)

本文链接:https://www.haomeiwen.com/subject/yokxyftx.html