[BS-24] UIImageView的contentMode属性
UIImageView的contentMode属性
UIViewContentModeScaleToFill, //默认使用该模式
UIViewContentModeScaleAspectFit, // contents scaled to fit with fixed aspect. remainder is transparent
UIViewContentModeScaleAspectFill, // contents scaled to fill with fixed aspect. some portion of content may be clipped.
UIViewContentModeRedraw, // redraw on bounds change (calls -setNeedsDisplay)
UIViewContentModeCenter, // contents remain same size. positioned adjusted.
UIViewContentModeTop,
UIViewContentModeBottom,
UIViewContentModeLeft,
UIViewContentModeRight,
UIViewContentModeTopLeft,
UIViewContentModeTopRight,
UIViewContentModeBottomLeft,
UIViewContentModeBottomRight,
这些值都代表什么意思呢?
UIViewContentModeScaleToFill:将图片任意伸缩至填充整个UIImageView(忽略原有的宽高比,只负责填充满,此模式下图片基本上都会变形)
UIViewContentModeScaleAspectFit: 将图片等比例伸缩,直到能把整张图片装进ImageView(图片不会变形,但ImageView中图片四周可能有空白)
UIViewContentModeScaleAspectFill: 将图片等比例伸缩,直到宽度等于UIImageView的宽度or图片的高度等于UIImageView的高度为止,然后将图片居中显示
UIViewContentModeRedraw : 调用了setNeedsDisplay方法时,就会将图片重新渲染.
UIViewContentModeCenter:居中显示
......简单的看英文就能懂的就不一一介绍了!
我们还可以设置超出边框的内容都剪掉:
topView.clipsToBounds = YES;
总结:
- 凡是带有Scale单词的,图片都会拉伸
- 同时带有Fill单词的,都会将ImageView填满,图片四周没有空隙
- 凡是带有Aspect单词的,图片都会保持原来的宽高比,图片不会变形
举例:新浪微博里面的图片,就是采用了UIViewContentModeScaleAspectFill这种模式来展示图片的。
图解:
[BS-24] UIImageView的contentMode属性的更多相关文章
- UIImageView 的contentMode属性应用
UIImageView 的contentMode这个属性是用来设置图片的显示方式,如居中.居右,是否缩放等,有以下几个常量可供设定:UIViewContentModeScaleToFillUIView ...
- UIImageView 的contentMode属性 浅析
UIImageView 的contentMode这个属性是用来设置图片的显示方式,如居中.居右,是否缩放等,有以下几个常量可供设定:UIViewContentModeScaleToFillUIView ...
- iOS开发-UIImageView的contentMode属性
UIImageView 的contentMode这个属性是用来设置图片的显示方式,如居中.居右,是否缩放等,有以下几个常量可供设定:UIViewContentModeScaleToFillUIView ...
- UIImageView 的contentMode属性
UIViewContentModeScaleToFill UIViewContentModeScaleAspectFit UIViewContentModeScaleAspectFill UIView ...
- UIImageView的contentMode属性
UIViewContentMode 都有哪些值: typedef NS_ENUM(NSInteger, UIViewContentMode) { UIViewContentModeScaleToFil ...
- IOS UIImageView的contentMode属性
红框表示imageView的frame,下面的图片是原图大小UIViewContentModeScaleToFill, 默认,对图片进行拉伸处理(不是按比例),是充满bouns UIVie ...
- FoxOne---一个快速高效的BS框架--WEB控件属性编辑器
FoxOne---一个快速高效的BS框架--(1) FoxOne---一个快速高效的BS框架--(2) FoxOne---一个快速高效的BS框架--(3) FoxOne---一个快速高效的BS框架-- ...
- 重写UIImageView的image属性
重写UIImageView的image属性 效果: 当你重写了UIImageView的image属性后你就会对UIImageView怎么显示图片了如指掌了:) 源码: UIImageView.h + ...
- 通过 CALayer 修改 UIImageView 的界面属性
界面属性的修改是每一个开发者必须知道的,为什么我就记不住呢, shit, 又耽误了时间,为了防止再找不到,特把一些常用的 CALayer属性记在这里,顺便分享 1.设置阴影 1 imageView.l ...
随机推荐
- JS - 超强大文本动画插件Textillate.js
http://www.yyyweb.com/demo/textillate/ Textillate.js AsimplepluginforCSS3textanimations.
- svn搭建,很简单
yum install subversion 2015年1月7日15:23:07 我测试的时间 系统是centos6.5 直接yum,centos是可以直接解决apr apr-util 依赖问题,如果 ...
- svn vs git
SVN和Git比较,哪个好用,适用? GIT和SVN之间的五个基本区别 话说Git的区别
- HDU 2087 kmp模板题
s为主串 t为模板串 求t的nextt 加const #include<stdio.h> #include<string.h> #include<algorithm> ...
- 【翻译】Kinect v1和Kinect v2的彻底比较
本连载主要是比较Kinect for Windows的现行版(v1)和次世代型的开发者预览版(v2),以C++开发者为背景介绍进化的硬件和软件.本文主要是对传感的配置和运行条件进行彻底的比较. ...
- oracle 多表查询
1.注意点 在查询过程中,不确定数据库表中的数据量,先查询数据量,数据量较大,则不能直接查询(select * from emp),如果数据量较大,直接查询容易造成死机或者数据读取较慢,如果较小可以查 ...
- maven run as(debug as)没有运行的选项时
run as - run configration -maven build- goal目录下填上:tomcat:run即可
- embody the data item with the ability to control access to itself
Computer Science An Overview _J. Glenn Brookshear _11th Edition Such communication needs have long b ...
- SQLQuery 实现别名映射
public List getQueryList(Map paramMap, int start, int maxResults) throws DataAccessException, Hibern ...
- phpcms v9模版调用代码大全(全面而实用)
首页调用栏目 {pc:content action="category" siteid="$siteid" num="15" order=& ...