UI---UIImageView
2015-10-17 19:08
477 查看
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;
相关文章推荐
- UI中横屏竖屏切换的一些方法(转)
- UI系统类继承树
- IOS 开发笔记-基础 UI(8)控件连线的 strong 和 weak 设定
- SPOJ GSS3 Can you answer these queries III
- SPOJ GSS2 Can you answer these queries II
- Guid
- Request和Response详解
- request对象和response对象
- EasyUI - SearchBox 搜索框
- UI----Touch
- 定制Segue - OverlaySegue
- EasyUI - pagination 分页组件
- UI--Gesture
- NGUI实现输入框和进度条
- 第一篇 UEditor入门部署和体验
- leetcode : 4 Median of Two Sorted Arrays
- POJ 3368 Frequent values
- 【学习总结】UIGestureRecognizer(手势识别器)
- EasyUI - SplitButton 分割按钮
- Android中bluetooth的架构