//
// 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. .Net 应用程序如何在32位操作系统下申请超过2G的内存【转】

    作者: eaglet 2008 年我写过一篇博客叫 <让.Net 应用程序突破2G的内存访问限制> 这篇博客主要讲述了如何在32位操作系统下利用AWE 扩展访问超过2G的内存.AWE方式虽 ...

  2. Out of resources when opening file 错误解决

    mysqldump: Got error: 23: Out of resources when opening file ‘./mydb/tax_calculation_rate_title.MYD’ ...

  3. python 调试工具

    https://github.com/what-studio/profiling http://blog.jobbole.com/51062/ http://blog.jobbole.com/5209 ...

  4. Python高级编程–正则表达式(习题)

    原文:http://start2join.me/python-regex-answer-20141030/ ############################################## ...

  5. The Socket API, Part 5: SCTP

    转:http://www.linuxforu.com/2011/12/socket-api-part-5-sctp/ By Pankaj Tanwar on December 29, 2011 in  ...

  6. kafka 简介

    1.  概述 Kafka是Linkedin于2010年12月份开源的消息系统,它主要用于处理活跃的流式数据,使用scala编写.活跃的流式数据在web网站应用中非常常见,这些数据包括网站的pv.用户访 ...

  7. ImageSource使用心得(转)

    很多时候,我们会使用图片来装饰UI,比如作为控件背景等. 而这些图片可以分为两种形式,即存在于本地文件系统中的图片和存在于内存中的图片 对于这两种形式的图片,在WPF中,使用方法不同,下面主要说明针对 ...

  8. IOS 应用中从竖屏模式强制转换为横屏模式

    在 iPhone 应用里,有时我们想强行把显示模式从纵屏改为横屏(反之亦然),CocoaChina 会员 “alienblue” 为我们提供了两种思路 第一种:通过人为的办法改变view.transf ...

  9. JavaScript中交换两个变量的值得三种做法(代码实现)

    javascript在编程时经常会涉及到如何交换两个变量的值,例如常见的冒泡排序,快速排序等:下面我讲根据自己近期所学总结几种常见的交换两个变量值的方法: 方法一:借助第三方变量交换两个变量的值 va ...

  10. 插件介绍 :cropper是一款使用简单且功能强大的图片剪裁jQuery插件。

    简要教程 cropper是一款使用简单且功能强大的图片剪裁jQuery插件.该图片剪裁插件支持图片放大缩小,支持鼠标滚轮操作,支持图片旋转,支持触摸屏设备,支持canvas,并且支持跨浏览器使用. c ...