UI---UIImageView
来源:互联网 发布:淘宝女装批发店铺有吗 编辑:程序博客网 时间:2024/04/29 17:11
UIImageView是iOS中⽤用于显⽰示图⽚片的类,iOS中⼏几乎所有看到的图⽚片,都是由这个类来显⽰示的.
NS_CLASS_AVAILABLE_IOS(2_0) @interface UIImageView : UIView { @private id _storage;}
上代码
UIImageView *imv = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds]; imv.backgroundColor = [UIColor cyanColor]; //第一种获取图片方式// imv.image = [UIImage imageNamed:@"1.jpg"];//如果是pnj格式的图片则可以省略格式名 //获取bundle里面图片的第二种形式 NSString *path = [[NSBundle mainBundle]pathForResource:@"1" ofType:@"jpg"];//@"1.jpg" nil //也可以写成 NSString *path = [[NSBundle mainBundle]pathForResource:@"1.jpg" ofType:nil]; /* 但不可以写成 NSString *path = [[NSBundle mainBundle]pathForResource:nil ofType:@"1.jpg"];*/ imv.image = [UIImage imageWithContentsOfFile:path];
添加动态图的方式
UIImage *img1 = [UIImage imageNamed:@"1.tiff"]; UIImage *img2 = [UIImage imageNamed:@"2.tiff"]; UIImage *img3 = [UIImage imageNamed:@"3.tiff"]; UIImage *img4 = [UIImage imageNamed:@"4.tiff"]; UIImage *img5 = [UIImage imageNamed:@"5.tiff"]; UIImage *img6 = [UIImage imageNamed:@"6.tiff"]; imv.animationImages = @[img1,img2,img3,img4,img5,img6]; //动画循环的次数 imv.animationRepeatCount = 10; //动画每次的时间 imv.animationDuration = 1; //让动画开始的方法 [imv startAnimating]; //让动画停止 [imv stopAnimating];#####//imageView默认的userInteractionEnabled是NO,会阻断响应链 //意思是如果在图片上面加了例如button这样需要相应的东西,就一定要把imageView的userInteractionEnabled设置为YES; imv.userInteractionEnabled = YES;
0 0
- UI-UIImageView
- UI---UIImageView
- 8、UIImageView-OC+UI
- UI控件 - UIImageView
- UI UIImageView的使用
- IOS UI控件 - UIImageView
- UI控件--UIImageView
- IOS UI 手写 UIImageView
- IOS--UI--LessonUIControl UIImageView/ UISegmentedControl
- iOS -UI-06 UIImageView 动画
- UI - UIImageView 和页面跳转
- UI - UISegmentedControl、UISlider、UIImageView、UISwitch
- UI之UILabel和UIImageView
- 05-常用UI控件之 UIImageView
- UI基础之-UIImage,UIImageView, UISegmentedControl,UISlider
- iOS UI篇 学习笔记 UIButton,UIImageView
- [IOS]今天开始学UI---UIImageView
- iOS之UI随笔-UIButton与UIImageView
- php pdo 连接db2 数据库
- Android Studio第一个项目创建报错解决办法
- 表单提交ckeditor并获取其值
- 第一个c语言程序 - c语言打印一句话
- iOS开发之C语言---for循环
- UI---UIImageView
- 路漫漫其修远兮,吾将上下而求索。
- RadASM的测试工程!
- iOS基础知识:if 语句以及if语句的使用注意事项
- IOS绘制图片水印以及文字水印
- addTarget各个参数的含义:
- v2
- ubuntu14.04 源码安装Qt 5.4
- Android Studio平台使用GreenDao操作数据库