UI_UIImageView 基本操作
来源:互联网 发布:常熟市东张镇淘宝地址 编辑:程序博客网 时间:2024/06/05 11:18
UI_UIImageView 常用方法
// 使用ImageView 通过 name 找到图片 UIImage *image = [UIImage imageNamed:@"bg_2"]; // 添加 image 到 imageView 上 UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; // 设置图片位置和大小 imageView.frame = CGRectMake(40, 40, 90, 160); imageView.backgroundColor = [UIColor redColor]; // 设置透明度 imageView.alpha = 0.5; // 为图片添加点击事件 // userInteractionEnabled 为 YES ,才能响应点击事件 imageView.userInteractionEnabled = YES; // 设置图片可以交互 // 设置手势 UITapGestureRecognizer *singleTag = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; // 添加手势 [imageView addGestureRecognizer:singleTag]; // 显示/隐藏 YES 为隐藏 imageView.hidden = NO; // 获取网络中的图片 UIImage *netImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"www.google.com"]]]; // 将 image 添加到 window 上,并释放内存 [self.window addSubview:imageView]; [imageView release]; imageView = nil; // 安全释放
动态图
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"1.tiff"]]; imageView.frame = CGRectMake(40, 50, 100, 100); // 把一组图片加到 imageView 上面 NSMutableArray *array = [NSMutableArray array]; for (int i = 1; i < 5; i++) {// NSString *name = [NSString stringWithFormat:@"00%d.tiff", i];// UIImage *image = [UIImage imageNamed:name]; // 上面两句可以合为一句 UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.tiff", i]]; [array addObject:image]; } // 把数组放到imageView中 imageView.animationImages = array; [self addSubview:imageView]; // 播放时间 imageView.animationDuration = 0.4f; // 播放次数 imageView.animationRepeatCount = 0; // 0 就是无限次 // 开始动画 [imageView startAnimating]; // 结束动画】// [imageView stopAnimating];
0 0
- UI_UIImageView 基本操作
- 基本操作
- 基本操作
- 基本操作
- 基本操作
- 基本操作
- 基本操作
- sparkSQL操作基本操作
- gitlab基本一些基本操作
- Matlab 基本命令、基本操作
- MySQL常用操作基本操作
- C#操作XML(基本操作)
- MySQL常用操作基本操作
- Python -- Json基本操作操作
- MySQL操作数据库基本操作
- MySQL基本操作 结构操作
- 操作mysql数据库基本操作
- Java 操作MongoDB 基本操作
- 源起自动化
- caffe-ubuntu14.04+64bit环境配置说明(GPU下运行)
- leetcode-105&106 Construct Binary Tree from Preorder and Inorder Traversal I&II
- [Leetcode]-Pascal's Triangle
- 参数估计、假设检验与回归
- UI_UIImageView 基本操作
- 警惕 MySql 更新 sql 的 WHERE 从句中的 IN() 子查询时出现的陷阱
- MFC对ini文件的操作
- 著名的互联网企业的面试笔试真题
- 排序 - 选择法
- LeetCode-Fraction to Recurring Decimal-解题报告
- 获取网络图片
- Matlab插值计算各时刻磁法勘探日变观测值
- 【前端网站】 前端(html、css、js)精品网站收藏