让UIImageView适应图片的大小
2015-12-09 21:47
489 查看
我在一个UIImageView中加入了一张图片,我想让这个图片的尺寸作为该UIImageView的尺寸。
先设为CGRectZero,再赋值也可以!!!!!
//创建imgV视图 -(void)createImgV { //创建视图展示 _imgV = [[UIImageView alloc] initWithFrame:CGRectZero]; _imgV.backgroundColor=[UIColor yellowColor]; // _imgV.contentMode = UIViewContentModeScaleAspectFit; _imgV.backgroundColor=[UIColor yellowColor]; _imgV.contentMode=UIViewContentModeScaleToFill; [self addSubview:_imgV]; } -(void)setImgName:(NSString *)imgName { _imgName = imgName; [_imgV setImageWithURL:[NSURL URLWithString:_imgName]]; _imgV.frame=CGRectMake(0, 0, _imgV.image.size.width, _imgV.image.size.height); }
先设为CGRectZero,再赋值也可以!!!!!
相关文章推荐
- iOS 关于UIImage的压缩问题
- Android 笔记:AndroidTrain , Lint , build.gradle , 第三方库
- ubuntu12.04+ros fuerte 跑LsdSlam代码
- iOS开发UI篇—以微博界面为例使用纯代码自定义cell程序编码全过程(三·完结)
- abdroid hwui
- Putty和Xming创建远程GUI的SSH连接
- android120 zhihuibeijing 开机页面
- ERROR (DiscoveryFailure): Could not determine a suitable URL for the plugin
- nsq源码阅读笔记之nsqd(三)——diskQueue
- UIImageView的图片居中问题
- UITextView使用
- leetcode Longest Consecutive Sequence
- Error:ERROR ITMS-90474: "Invalid Bundle. iPad Multitasking support requires these orientations:
- Could not execute JDBC batch update : java.sql.BatchUpdateException: ORA-00926: 缺失 VALUES 关键字
- UE4连接Oculuse DK2设备
- UGUI之页面滑动(Grid Layout和Scorll Rect&&mask)
- [leetcode]Unique Paths II
- [leetcode]Unique Paths
- Exception:exception setting property value with CGLIB
- UISearchDisplayController简单使用