2016-1-8 Quartz框架的学习,多个气球上升的小动画
//
// BallonView.m
// 气球上升的动画
//
// Created by Mac on 16/1/8.
// Copyright © 2016年 Mac. All rights reserved.
// #import "BallonView.h"
@interface BallonView() @property (nonatomic, assign) NSString *postions;
@property (nonatomic, strong) CADisplayLink *link;
@property (nonatomic, strong) NSMutableArray *locations;
@property (nonatomic, strong) NSMutableArray *ballons; @end
@implementation BallonView
//懒加载 存储位置
- (NSMutableArray *)locations
{
if (!_locations) {
_locations = [NSMutableArray array];
}
return _locations;
}
- (NSMutableArray *)ballons
{
if (!_ballons) {
_ballons = [NSMutableArray array];
NSInteger count = ;
UIImage *ballonImage =[UIImage imageNamed:@"sandyBalloon"];
for (int i = ; i < count; i ++) {
CGFloat left = ;
CGPoint location = CGPointMake(left*(i+), self.frame.size.height - );
// [ballonImage drawAtPoint:location];
[self.locations addObject:[NSValue valueWithCGPoint:location]];
[_ballons addObject:ballonImage];
}
}
return _ballons;
} // Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
NSInteger ballonsOfCount = self.ballons.count;
for (int i = ; i < ballonsOfCount; i ++) {
// 获取气球的位置
CGPoint postion = [self.locations[i] CGPointValue];
postion.y -= arc4random_uniform() * 0.7;
if (postion.y == ) {
postion.y = rect.size.height;
} [self.locations replaceObjectAtIndex:i withObject:[NSValue valueWithCGPoint:postion]];
[self.ballons[i] drawAtPoint:postion];
}
NSLog(@"%s",__func__); } // ------------------------------------------------------------------------------------------------------------------
// Drawing code - (instancetype)init
{
if (self = [super init]) {
[self addAnimition];
}
return self;
}
- (void) addAnimition
{
// [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(setNeedsDisplay) userInfo:nil repeats:YES];
CADisplayLink *link = [CADisplayLink displayLinkWithTarget:self selector:@selector(setNeedsDisplay)];
[link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
self.link = link;
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
[self.link invalidate];
} @end

2016-1-8 Quartz框架的学习,多个气球上升的小动画的更多相关文章
- 2016-1-9 Quartz框架的学习,写字板demo
一:自定义view .h文件中代码如下 #import <UIKit/UIKit.h> @interface ZLpaintView : UIView @property(nonatomi ...
- 2016-1-9 Quartz框架的学习,剪裁图片并设置边框
#import "ViewController.h" @interface ViewController () @end @implementation ViewControlle ...
- pythonweb框架Flask学习笔记02-一个简单的小程序
#-*- coding:utf-8 -*- #导入了Flask类 这个类的实例将会是我们的WSGI应用程序 from flask import Flask #创建一个Flask类的实例 第一个参数是应 ...
- Quartz框架学习(1)—核心层次结构
Quartz框架学习 Quartz(任务调度)框架的核心组件: job:任务.即任务调度行为中所要调度的对象. trigger:触发器.是什么促使了一个任务的调度?当然是时间.这也算事件驱动类型程序. ...
- Quartz框架(第一版)
任务调度 在企业级应用中,经常会制定一些"计划任务",即在某个时间点做某件事情 核心是以时间为关注点,即在一个特定的时间点,系统执行指定的一个操作 任务调度涉及多线程并发.线程池维 ...
- Quartz框架
Quartz框架 Quartz 是个开源的作业调度框架,为在 Java 应用程序中进行作业调度提供了简单却强大的机制.Quartz 允许开发人员根据时间间隔(或天)来调度作业.它实现了作业和触发器的多 ...
- spring整合Quartz框架过程,大家可以参考下
这篇文章详细介绍了spring集成quartz框架流程,通过示例代码进行了详细说明,对学习或任务有参考学习价值,并可供需要的朋友参考. 1.quartz框架简介(m.0831jl.com) quart ...
- DBFlow框架的学习笔记之入门
什么是DBFlow? dbflow是一款android高性的ORM数据库.可以使用在进行项目中有关数据库的操作.github下载源码 1.环境配置 先导入 apt plugin库到你的classpat ...
- 【淘淘】Spring整合Quartz框架
我在外面工作实习的时候,我们做的项目是一个日报子系统,也就是定时定点为公司生成一些报表数据还有一些数据反馈.这时候我们会经常用到定时任务,比如每天凌晨生成前天报表,每一小时生成汇总数据等等.当时,我做 ...
随机推荐
- Jquery如何获得<iframe>嵌套页面中的元素
DOM方法:父窗口操作IFRAME:window.frames["iframeSon"].documentIFRAME操作父窗口: window.parent.documentjq ...
- css清除默认样式和设置公共样式
/*公共样式--开始*/ html, body, div, ul, li, h1, h2, h3, h4, h5, h6, p, dl, dt, dd, ol, form, input, textar ...
- sh脚本异常:bad interpreter: No such file or directory
转:http://bluedest.iteye.com/blog/1674963 在Linux中执行.sh脚本,异常/bin/sh^M: bad interpreter: No such file o ...
- 18. 4Sum -- 找到数组中和为target的4个数
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = tar ...
- Java--常用类summary(二)
/* 1:StringBuffer(掌握) (1)用字符串做拼接,比较耗时并且也耗内存,而这种拼接操作又是比较常见的,为了解决这个问题,Java就提供了 一个字符串缓冲区类.StringBuffer供 ...
- 时间序列数据库选型——本质是列存储,B-tree索引,抑或是搜索引擎中的倒排索引
时间序列数据库最多,使用也最广泛.一般人们谈论时间序列数据库的时候指代的就是这一类存储.按照底层技术不同可以划分为三类. 直接基于文件的简单存储:RRD Tool,Graphite Whisper.这 ...
- ccpc 2016 省赛
1.configuration if ide. 2.file import and export. 3.check your program more than once. ============= ...
- 第一个简单的DEMO
一个联系人管理的DEMO,支持CURD 运行效果图: Controller的设计: 总结: Web API的Controller都继承自ApiController. Web API的Action的命名 ...
- mysql有回滚,php没有回滚的说法
mysql 事务表是有回滚的说法.当发生mysql层面的错误才会执行回滚
- 配置coffeeScript
1.安装好node.js后 在系统环境变量自动会设置好: 我安装在D:\Program Files文件夹中 也安装好了npm(node packges manager) 2.系统会自动配置np ...