ui--UIimage And UIIimageView
来源:互联网 发布:时时彩组三报警软件 编辑:程序博客网 时间:2024/05/17 23:01
【UIImage】和【UIImageView】
//图片视图 UIImage UIImageView
【注】UIImage和UIImageView的关系,近似于NSString和UILabel的关系。
一.UIImage的取图方式
1、通过图片姓名获取图片
+ (UIImage *)imageNamed:(NSString *)name; //会将图片读到内存中
因此imageNamed的优点是当加载时会缓存图片到本地。所以当图片会频繁的使用时,那么用imageNamed的方法会比较好。
2、根据图片的路径获取图片 //不会把图片读到内存中
//先获得图片在App包内的路径
NSString *path=[[NSBundlemainBundle]pathForResource:@"DOVE 1"ofType:@"png"]
+ (UIImage *)imageWithContentsOfFile:(NSString *)path;
imageWithContentsOfFile:仅加载图片,图像数据不会缓存。因此对于较大的图片以及使用情况较少时,那就可以用该方法,降低内存消耗
二.图片视图的基本使用
常用属性:
//设置静态图片
@property(nonatomic,retain)UIImage *image;
//imageView中的图片 方法
先创建图片视图UIImageView *imageView =[[UIImageView alloc]initWithFrame:CGRectMake(xx, xx, xx, xx)];
imageView1.image=[UIImage imageNamed:@“图片的名称”];
@property(nonatomic)UIViewContentModecontentMode;
// default is UIViewContentModeScaleToFill
// UIViewContentModeScaleToFill 拉伸填满,缺省
// UIViewContentModeScaleAspectFit 按比例填充
// UIViewContentModeScaleAspectFill 按比例填满
三.图片视图的动画效果
这个一般和+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)yesOrNo放在一起用。
//设置动画图片数组
imageView.animationImages = array;
//设置动画时间,是全部图片切换一次的时间
imageView.animationDuration =1.5;
//设置动画重复次数,设为0是无限次
imageView.animationRepeatCount =0;
//启动动画
[imageView startAnimating];
//停止动画
[imageView stopAnimating];
- ui--UIimage And UIIimageView
- ui视图之uiimage
- UI基础:UIButton.UIimage
- IOS--UI--LessonButton UIImage
- UIImage and NSCoding
- [UI界面]-UIImage的拉伸
- UIIImageView 播放图片动画
- UI基础之-UIImage,UIImageView, UISegmentedControl,UISlider
- iOS UIimage和UI color转换
- creating and drawing on a new UIImage
- UIImageview and UIImage 之Swift学习
- uiimage
- UIImage
- UIImage
- UIImage
- UIImage
- UIImage
- UIImage
- opnet之queue之acb_fifo
- MySQL案例二
- 【读书笔记】Android 输入系统
- 云服务器centos7.2安装amp环境
- 多线程--异步任务AsyncTask由浅入深探究
- ui--UIimage And UIIimageView
- CMMB中的H264和AAC打包成ts流
- 堆排序
- java之基础常识(一)
- HibernateのHQL操作
- Android新技术
- PostgreSQL9.6+PostGIS2.3学习笔记(二)常用函数以及JDBC连接
- ECMAScript6(ES6)标准之let、const关键字与块级作用域
- Excle 实现数据0,1 的离差标准化