//
// 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. [Angular2 Router] CanActivate Route Guard - An Example of An Asynchronous Route Guard

    In this tutorial we are going to learn how we can to configure an can activate route guard in the An ...

  2. SQL Server事务日志介绍

    SQL Server中的数据库都是由一或多个数据文件以及一或多个事务日志文件组成的. 顾名思意,数据文件主要存储数据库的数据,包括数据库内容结构,数据页,索引页等等.那么事务日志到底是干什么的呢?它主 ...

  3. Linux上安装使用boost入门指导

    Data Mining Linux上安装使用boost入门指导 获得boost boost分布 只需要头文件的库 使用boost建立一个简单的程序 准备使用boost二进制文件库 把你的程序链接到bo ...

  4. 使用java8

    刚开始一直使用的jdk7,但是学习spark的时候spark推荐Jdk8,很多示例程序都用到了lambda 机器上安装jdk8只是实验用途,默认还想使用jdk7 安装完后 网上说这是因为jdk8安装的 ...

  5. CSS 之 嵌套 margin-top 处理

    如下代码: <div style=" width:1000px; height:700px; margin:auto;"> <div style=" w ...

  6. C# mvc--EF中查询的本质

    UI层我直接用了窗体程序. 好了 不罗嗦 直接上代码…… private void button1_Click(object sender, EventArgs e) { //1.0创建EF上下文容器 ...

  7. IOS 应用 退出的一个小方法

    AppDelegate * app=(AppDelegate *)[[UIApplication sharedApplication]delegate]; UIWindow *window = app ...

  8. MVC+easyui 完整实现

    学习mvc半月有余,趁几天假期,没事做就动手做一个完整的网站玩玩,顺便和上家公司的方法做个比较.页面引擎采用mvc自带的功能,建立视图,交给.net自带渲染出页面(对比:上家公司采用的第三方组件渲染的 ...

  9. 【Shell脚本学习17】Shell case esac语句

    case ... esac 与其他语言中的 switch ... case 语句类似,是一种多分枝选择结构. case 语句匹配一个值或一个模式,如果匹配成功,执行相匹配的命令.case语句格式如下: ...

  10. 【Android 界面效果21】Android ViewPager使用详解

    这是谷歌官方给我们提供的一个兼容低版本安卓设备的软件包,里面包囊了只有在安卓3.0以上可以使用的api.而viewpager就是其中之一利用它,我们可以做很多事情,从最简单的导航,到页面菜单等等.那如 ...