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框架
我在外面工作实习的时候,我们做的项目是一个日报子系统,也就是定时定点为公司生成一些报表数据还有一些数据反馈.这时候我们会经常用到定时任务,比如每天凌晨生成前天报表,每一小时生成汇总数据等等.当时,我做 ...
随机推荐
- robotframework笔记9
列表和字典 通过专用关键字创建了列表和字典.我们将在这里看到创建的两个例子 ︰ 选择 *** Settings *** Library BuiltIn Library Collections *** ...
- 小例子(三)、winform控件的移动
程序:Do You Love Me ? 说明:就是鼠标移动到“不爱”按钮上按钮就会移动到其他地方 代码: //鼠标进入控件表面的事件MouseEnter //this.ClientSize.Width ...
- 自定义jQuery插件Step by Step
1.1.1 摘要 随着前端和后端技术的分离,各大互联网公司对于 Mobile First理念都是趋之若鹜的,为了解决网页在不同移动设备上的显示效果,其中一个解决方案就是Responsive Desig ...
- Java 集合系列 17 TreeSet
java 集合系列目录: Java 集合系列 01 总体框架 Java 集合系列 02 Collection架构 Java 集合系列 03 ArrayList详细介绍(源码解析)和使用示例 Java ...
- 【转】数据库范式(1NF 2NF 3NF BCNF)详解一
以下内容转自:http://jacki6.iteye.com/blog/774866 --------------------------------------------分割线---------- ...
- win7_64bit下桌面及开始菜单中图标变为.lnk
以下内容参考整理与MSDN: 1.首先 win+r 2.打开运行程序 3.输入: regedit 4.找到: 计算机\HKEY_CURRENT_USER\SOFTWARE\MICROSOFT\WIND ...
- freemarker实例2
下面演示一个简单的使用项目过程:1. 使用myeclipse创建一个web项目testFM2. 把下载到的jar包(freemarker-2.3.9.jar)放到/WebRoot/WEB-INF/li ...
- shell学习记录001-知识点储备
1.BASH(bourne again shell ) cmd1 ;cmd2等同于 cmd1 cmd2 2.echo music; 中的分号不被打印出,因为分号默认为命令定界符号 3.利用pgrep找 ...
- Android第三方开源对话消息提示框:SweetAlertDialog(sweet-alert-dialog)
Android第三方开源对话消息提示框:SweetAlertDialog(sweet-alert-dialog) Android第三方开源对话消息提示框:SweetAlertDialog(sweet- ...
- 判断是否是iOS8
判断是否是iOS8 //判断是否是iOS8 if ([[UIDevice currentDevice].systemVersion doubleValue]>=8.0) { NSLog(@&qu ...