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的更多相关文章
随机推荐
- GridView编辑删除操作
第一种:使用DataSource数据源中自带的编辑删除方法,这样的不经常使用,在这里就不加说明了. 另外一种:使用GridView的三种事件:GridView1_RowEditing(编辑).Grid ...
- linux man使用方法 和centos安装中文man包 --转
http://blog.chinaunix.net/uid-25100840-id-302308.html 这两天学习<linux设备驱动程序开发详解>中的异步通知,其中有一个fcntl( ...
- SimpleUrlHandlerMapping 处理器映射的配置--转
http://blog.csdn.net/rainier001/article/details/6860491 <?xml version="1.0" encoding=&q ...
- 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 ...
- javascript函数中的实例对象、类对象、局部变量(局部函数)
定义 function Person(national,age) { this.age = age; //实例对象,每个示例不同 Person.national = national; //类对象,所 ...
- iso8583报文自学笔记
一.8583报文组成 TPDU 报文头 应用数据 ISO8583 Msg ID 目的 地址 源地址 应用类别定义 软件 总版本号 终端 状态 处理 要求 保留使用(软件分版本号) 交易数据 60H N ...
- Wamp,XAMPP 无法启动,端口未占用的故障处理
打开服务管理里:Service.msc 找到服务:WinHttpAutoProxySvc(WinHTTP 实现了客户端 HTTP 堆栈并向开发人员提供 Win32 API 和 COM 自动化组件以供发 ...
- 自动备份并保存最近几天的SQL数据库作业脚本
DECLARE @filename VARCHAR(255) DECLARE @date DATETIME SELECT @date=GETDATE() SELECT @filename = 'G:\ ...
- C语言中的命名空间
C语言中的命名空间 命名空间是为了解决 "在相同作用域内如何区分 相同的标识符". 说明: ①只有在相同作用域的情况下才能使用到命名空间去区分标识符,在嵌套的作用域.不同的作用域区 ...
- String类的方法2
---恢复内容开始--- .ToLower() //转为小写字符串"AbC"-->"abc" .ToUpper() //转为大写"A ...