UI4_UIImageView
//
// ViewController.m
// UI4_UIImageView
//
// Created by zhangxueming on 15/7/1.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//ImageView --- 显示图片 NSString *path =[[NSBundle mainBundle] pathForResource:@"map" ofType:@"png"];
//NSLog(@"path = %@", path); //加载图片,通常加载大图片,效率低一点
UIImage *image = [UIImage imageWithContentsOfFile:path]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame =CGRectMake(10, 100, self.view.frame.size.width-20, 400);
[self.view addSubview:imageView]; //添加手势
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView)];
//设置点击次数
tap.numberOfTapsRequired = 1;
//设置触摸点个数
tap.numberOfTouchesRequired = 1;
//使能imageView用户交互
imageView.userInteractionEnabled =YES;
//添加手势到imageView上
[imageView addGestureRecognizer:tap]; NSMutableArray *imageArray = [NSMutableArray array];
for (int i=0; i<12; i++) {
NSString *imageName = [NSString stringWithFormat:@"player%d",i+1];
UIImage *image = [UIImage imageNamed:imageName];
[imageArray addObject:image];
} UIImageView *aniImageView = [[UIImageView alloc] initWithFrame:CGRectMake(150, 200, 100, 100)];
aniImageView.tag = 100;
aniImageView.animationImages =imageArray;
//
[self.view addSubview:aniImageView]; //设置动画播放时间
aniImageView.animationDuration = 2.0;
//开始播放动画
[aniImageView startAnimating]; } - (void)tapImageView
{
NSLog(@"imageView 被点击");
static BOOL aniState = YES;
UIImageView *imageView = (UIImageView *)[self.view viewWithTag:100];
if (aniState) {
[imageView stopAnimating];
aniState = NO;
}
else
{
[imageView startAnimating];
aniState = YES;
}
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
UI4_UIImageView的更多相关文章
随机推荐
- NGUI ERROR:UnityException: Sprite is not rectangle-packed. TextureRect is invalid.解决
在使用Ngui 3.4.9的时候,使用“Unity 2D Sprite”控件的时候,出现了UnityException: Sprite is not rectangle-packed. Texture ...
- Android创建文件夹及文件并写入数据
package elwin.fei.mobileaudio; import java.io.BufferedWriter; import java.io.File; import java.io.Fi ...
- HDU1003 Max Sum(求最大字段和)
事实上这连续发表的三篇是一模一样的思路,我就厚颜无耻的再发一篇吧! 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1003 -------------- ...
- 基数树(radix tree)
原文 基数(radix)树 Linux基数树(radix tree)是将指针与long整数键值相关联的机制,它存储有效率,并且可快速查询,用于指针与整数值的映射(如:IDR机制).内存管理等.ID ...
- Linux文件系统的几个性能测试软件小结
曾经测试Linux系统下的分布式集群系统的性能,使用了一些测试软件,公司让我给部门同事做一次基础培训,于是翻看以前所写的记录资料挑选了其中几个,所记之处并不完全,只记录使用的功能. 1.Iozone ...
- 实现O(1)获取最大最小值的栈----java
原文:http://blog.csdn.net/sheepmu/article/details/38459165 实现O(1)获取最大最小值的栈和队列----java 一.如何实现包含获取最小值函数的 ...
- GifCam
转载:http://blog.bahraniapps.com/?page_id=21 下载 http://pan.baidu.com/s/1c0vdHIw GifCam Note:GifCam c ...
- spark HA
spark HA 的两种实现: 基于文件系统的单点恢复(Single-Node Recovery with Local File System) 基于zookeeper的Standby Masters ...
- 开发工具 之 PowerDesigner 应用积累
1.在默认情况下,code与name是联动,修改了name中的数据. 解决方法:设置菜单栏选择"Tools→General Options→Dialog" 中的 "Na ...
- java发送邮件 实现编辑html代码
这个例子相当的简单,一看就懂( 此例仅支持163发送163及qq邮箱) 首先要导入两个必须jar包:mail-1.4.4.jar 和 commons-email-1.2.jar这两个jar包是我用的 ...