//
// 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. Oracle 数据文件管理

    1.手工改变数据文件的大小 SQL>conn / as sysdba SQL>Createtablespace exampletb Datafile 'E:\ examp01.dbf' s ...

  2. Understanding Linux Kernel version 3 读书笔记

    P30, preemptive  kernel .kernel threading 和Multithreaded application support没太好理解,我想如果设计个多线程的程序来运行运行 ...

  3. 在Swift中的ASCII到字符转换的问题

    我们在C++里处理字符通常是这样的 char a = 'A' // A = 65 printf("'%c' = %d", a + 1, a + 1) // 'B' = 66 这在号 ...

  4. PHP中header用法详解带范例(转)

    header的用法 header()函数的作用是:发送一个原始 HTTP 标头[Http Header]到客户端.标头 (header) 是服务器以 HTTP 协义传 HTML 资料到浏览器前所送出的 ...

  5. PHP __autoload函数(自动载入类文件)的使用方法(转)

    详细出处参考:http://www.jb51.net/article/29625.htm 在使用PHP的OO模式开发系统时,通常大家习惯上将每个类的实现都存放在一个单独的文件里,这样会很容易实现对类进 ...

  6. Ubuntu下VSFTPD(四)(vsftpd其它主要设置)

    vsftpd 服务器的其它主要设置 : 1 .最大传输速率设置: 设置匿名用户的最大传输率为20Kbps,修改/etc/vsftpd/vsftpd.conf 添加语句:anon_max_rate=20 ...

  7. PHPDoc/PHPDocumentor生成API文档

    PHPDocumentor是一个用PHP写的强大的文档自动生成工具,对于有规范注释的php程序,能够快速生成具有结构清晰.相互参照.索引等功能的API文档.旧版本是PHPDoc,PHPDoc是PEAR ...

  8. tachyon 命令行接口

    Usage: tachyon COMMAND where COMMAND is one of: format [-s] 格式化Format Tachyon (如果指定 -s 参数,表示在 underf ...

  9. 3.2html学习笔记之图片

    <img src="" width="50%" alt="加载时候或无法显示时候显示的文字" height="让浏览器预先给 ...

  10. ArcGIS 投影转换(AE)

    private void btnOK_Click(object sender, EventArgs e) { try { CheckError(); this.checkEdit1.Enabled = ...