iOS飘雪的动画小demo
ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController{
UIImage* flakeImage;
}
- (void)onTimer;
@end
ViewController.m #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithRed:0.5 green:0.5 blue:1.0 alpha:1.0];
flakeImage = [UIImage imageNamed:@"2.png"];
[NSTimer scheduledTimerWithTimeInterval:(0.05) target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
}
- (void)onTimer
{
//创建图像视图对象
UIImageView* flakeView = [[UIImageView alloc] initWithImage:flakeImage]; int startX = round(random() % );
int endX = round(random() % );
double scale = / round(random() % ) + 1.0;
double speed = / round(random() % ) + 1.0;
flakeView.frame = CGRectMake(startX, -100.0, 25.0 * scale, 25.0 * scale);
flakeView.alpha = 0.5;
[self.view addSubview:flakeView];
[UIView beginAnimations:nil context:(__bridge void *)(flakeView)];
[UIView setAnimationDuration: * speed];
flakeView.frame = CGRectMake(endX, 540.0, 25.0 * scale, 25.0 * scale);
[UIView commitAnimations]; } - (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
图片素材,通过Main.storyboard设置背景图片


iOS飘雪的动画小demo的更多相关文章
- 写个关于使用cocostudio Armature实现动画自由切换的小demo
这是一个关于使用cocostudio实现动画自由切换的小demo auto sprite =Sprite::create("background.png"); sprite-> ...
- AJ学IOS 之CoreLocation地理编码小Demo输入城市得到经纬度
AJ分享,必须精品 一:效果 输入地名,可以得到相应的经纬度,知识为了学习写的小Demo 二:实现步骤 一 :首先获取用户输入的位置. 二 :创建地理编码对象. 三 :利用地理编码对象编码,根据传入的 ...
- iOS 转场动画探究(一)
什么是转场动画: 转场动画说的直接点就是你常见的界面跳转的时候看到的动画效果,我们比较常见的就是控制器之间的Push和Pop,还有Present和Dismiss的时候设置一下系统给我们的modalTr ...
- iOS 转场动画探究(二)
这篇文章是接着第一篇写的,要是有同行刚看到的话建议从前面第一篇看,这是第一篇的地址:iOS 转场动画探究(一) 接着上一篇写的内容: 上一篇iOS 转场动画探究(一)我们说到了转场要素的第四点,把那个 ...
- iOS之一些实用的Demo
图像浏览及处理 FLAnimatedImage - gif播放处理的工具. CLImageEditor - 超强的图片编辑库,快速帮你实现旋转,防缩,滤镜等等一系列麻烦的事情. ios-image-f ...
- iOS CAReplicatorLayer 简单动画
代码地址如下:http://www.demodashi.com/demo/11601.html 写在最前面,最近在看学习的时候,偶然间发现一个没有用过的Layer,于是抽空研究了下,本来应该能提前记录 ...
- ios开发中的小技巧
在这里总结一些iOS开发中的小技巧,能大大方便我们的开发,持续更新. UITableView的Group样式下顶部空白处理 //分组列表头部空白处理 UIView *view = [[UIViewal ...
- 转 iOS Core Animation 动画 入门学习(一)基础
iOS Core Animation 动画 入门学习(一)基础 reference:https://developer.apple.com/library/ios/documentation/Coco ...
- iOS学习——核心动画
iOS学习——核心动画 1.什么是核心动画 Core Animation(核心动画)是一组功能强大.效果华丽的动画API,无论在iOS系统或者在你开发的App中,都有大量应用.核心动画所在的位置如下图 ...
随机推荐
- axios使用思路总结
一.Axios是什么?用来发送请求的对象,类似之前的ajax 二.如何使用? 目前只说get和post的使用方式.一共有两种. 直接使用配置项的方式,发送请求: 2.使用别名来发送请求 参考: htt ...
- java中 二进制 八进制 十六进制 十进制 相互转换 最简方法
package com.swift; import java.util.Scanner; public class Hex2Decimal { public static void main(Stri ...
- 第十一篇、UITableView headerview下拉放大
核心代码: -(void)createTableViewHeaderView{ _tableViewHeaderView = [[UIView alloc] initWithFrame:(CGRect ...
- 一个简单的linux下设置定时执行shell脚本的示例
很多时候我们有希望服务器定时去运行一个脚本来触发一个操作,比如说定时去备份服务器数据.数据库数据等 不适合人工经常做的一些操作这里简单说下 shell Shell俗称壳,类似于DOS下的command ...
- JZOJ 5197. 【NOIP2017提高组模拟7.3】C
5197. [NOIP2017提高组模拟7.3]C Time Limits: 1000 ms Memory Limits: 262144 KB Detailed Limits Goto Pro ...
- nowcoder N约数个数
n的约数个数 题目:t次询问,每次给你一个数n,求在[1,n]内约数个数最多的数的约数个数 数据:对于100%的数据,t <= 500 , 1 <= n <= 10000000000 ...
- [bzoj1912]异象石(set)
Description Adera是Microsoft应用商店中的一款解谜游戏. 异象石是进入Adera中异时空的引导物,在Adera的异时空中有一张地图.这张地图上有N个点,有N-1条双向边把它们连 ...
- 解决Uva网站打开慢的问题
https://blog.csdn.net/richenyunqi/article/details/80990535
- Sicily 8843 Ranking and Friendship
http://soj.me/8843 题意:几个人想做好朋友,朋友之间相差位置小于等于k,且长度相同分析:排序,将长度相同的放在一起.若长度相同,第i个人能放进去的条件是位置相差下雨等于k. ...
- HDU 5657 CA Loves Math 状压DP + 枚举
题意: 给出\(A(2 \leq A \leq 11), n(0 \leq n \leq 10^9), k(1 \leq k \leq 10^9)\). 求区间\([1, A^n]\)中各个数字互不相 ...