//
// 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的更多相关文章

随机推荐

  1. k-means聚类JAVA实例

    <mahout in action>第六章. datafile/cluster/simple_k-means.txt数据集例如以下: 1 1 2 1 1 2 2 2 3 3 8 8 8 9 ...

  2. 《Java虚拟机原理图解》 1.2、class文件里的常量池

    [最新更新:2014/11/11]  了解JVM虚拟机原理 是每个Java程序猿修炼的必经之路. 可是因为JVM虚拟机中有非常多的东西讲述的比較宽泛.在当前接触到的关于JVM虚拟机原理的教程或者博客中 ...

  3. opencv china 网站,好1376472449

    http://www.opencvchina.com/thread-1750-1-2.html

  4. [Express] Level 4: Body-parser -- Delete

    Response Body What would the response body be set to on a DELETE request to /cities/DoesNotExist ? H ...

  5. MAC下配置gradle用eclipse 打包android程序

    1.下载gradle binhttp://gradle.org/gradle-download/ 2.配置gradle,http://www.douban.com/note/311599602/htt ...

  6. Ubuntu下安装可视化SVN客户端Rabbitvcs

    如果你用过Windows下的tortoisesvn,肯定会感叹,同样是开源程序,为什么这些开源的东西不在开源的系统上先跑呢? 不用着急,那边有个乌龟,这篇有只兔子,只是看了太多的龟兔赛跑的故事,不知到 ...

  7. RHEL 7 命令行注册和激活订阅服务

    导读 前一阵子,红帽推出了开发者免费使用订阅功能,只要注册成为红帽开发者就可以免费使用包括  RHEL7  在内的开发套件. 今天我们就来看一看怎么使用命令行来快速注册和激活订阅服务,以后就可以方便地 ...

  8. centos下编译安装mysql5.6

    CentOS 6.4下编译安装MySQL 5.6.14 参考:http://www.cnblogs.com/xiongpq/p/3384681.html 概述: CentOS 6.4下通过yum安装的 ...

  9. jodd-StringTemplateParser使用

    StringTemplateParser 时一个string模板的解析器.在string模板中定义类似jsp标签的宏. 在解析过程中,宏被对值替换,值通过自定义的MacroResolver解析得到. ...

  10. E - 娜娜梦游仙境系列——莫名其妙的插曲

    E - 娜娜梦游仙境系列——莫名其妙的插曲 E - 娜娜梦游仙境系列——莫名其妙的插曲 Time Limit: 2000/1000MS (Java/Others)    Memory Limit: 1 ...