UIImageView 的contentMode这个属性是用来设置图片的显示方式,如居中、居右,是否缩放等,有以下几个常量可供设定:
UIViewContentModeScaleToFill
UIViewContentModeScaleAspectFit
UIViewContentModeScaleAspectFill
UIViewContentModeRedraw
UIViewContentModeCenter
UIViewContentModeTop
UIViewContentModeBottom
UIViewContentModeLeft
UIViewContentModeRight
UIViewContentModeTopLeft
UIViewContentModeTopRight
UIViewContentModeBottomLeft
UIViewContentModeBottomRight

注意以上几个常量,凡是没有带Scale的,当图片尺寸超过 ImageView尺寸时,只有部分显示在ImageView中。UIViewContentModeScaleToFill属性会导致图片变形。UIViewContentModeScaleAspectFit会保证图片比例不变,而且全部显示在ImageView中,这意味着ImageView会有部分空白。UIViewContentModeScaleAspectFill也会证图片比例不变,但是是填充整个ImageView的,可能只有部分图片显示出来。

typedef NS_ENUM(NSInteger, UIViewContentMode) {
// 铺满imageView
UIViewContentModeScaleToFill,
// 保证图片比例不变 全部显示在imageView中(意味imageView会有一些空白)
UIViewContentModeScaleAspectFit, // contents scaled to fit with fixed aspect. remainder is transparent
// 保证图片比例不变 宽或高相对短的那一边等于imageVIew(相当于图片会超出imageView)
UIViewContentModeScaleAspectFill, // contents scaled to fill with fixed aspect. some portion of content may be clipped.
// 每次设置或者更改frame会调用drawRect
UIViewContentModeRedraw, // redraw on bounds change (calls -setNeedsDisplay)
UIViewContentModeCenter, // contents remain same size. positioned adjusted.
UIViewContentModeTop,
UIViewContentModeBottom,
UIViewContentModeLeft,
UIViewContentModeRight,
UIViewContentModeTopLeft,
UIViewContentModeTopRight,
UIViewContentModeBottomLeft,
UIViewContentModeBottomRight,
};

UIImageView 的contentMode属性 浅析的更多相关文章

  1. [BS-24] UIImageView的contentMode属性

    UIImageView的contentMode属性   所有的UIView都有个contentMode属性,UIImageView继承自UIView,我们在使用UIImageView时,经常要考虑这些 ...

  2. UIImageView 的contentMode属性应用

    UIImageView 的contentMode这个属性是用来设置图片的显示方式,如居中.居右,是否缩放等,有以下几个常量可供设定:UIViewContentModeScaleToFillUIView ...

  3. iOS开发-UIImageView的contentMode属性

    UIImageView 的contentMode这个属性是用来设置图片的显示方式,如居中.居右,是否缩放等,有以下几个常量可供设定:UIViewContentModeScaleToFillUIView ...

  4. UIImageView 的contentMode属性

    UIViewContentModeScaleToFill UIViewContentModeScaleAspectFit UIViewContentModeScaleAspectFill UIView ...

  5. UIImageView的contentMode属性

    UIViewContentMode 都有哪些值: typedef NS_ENUM(NSInteger, UIViewContentMode) { UIViewContentModeScaleToFil ...

  6. IOS UIImageView的contentMode属性

    红框表示imageView的frame,下面的图片是原图大小UIViewContentModeScaleToFill,       默认,对图片进行拉伸处理(不是按比例),是充满bouns UIVie ...

  7. 重写UIImageView的image属性

    重写UIImageView的image属性 效果: 当你重写了UIImageView的image属性后你就会对UIImageView怎么显示图片了如指掌了:) 源码: UIImageView.h  + ...

  8. 通过 CALayer 修改 UIImageView 的界面属性

    界面属性的修改是每一个开发者必须知道的,为什么我就记不住呢, shit, 又耽误了时间,为了防止再找不到,特把一些常用的 CALayer属性记在这里,顺便分享 1.设置阴影 1 imageView.l ...

  9. iBATIS缓存cacheModel属性浅析

    iBATIS缓存cacheModel属性的应用使得在Mapped Statement中缓存常用的数据,那么本文将会给你介绍iBATIS缓存cacheModel属性的信息. AD:2013云计算架构师峰 ...

随机推荐

  1. osg + cuda

    #include <osg/Notify> #include <osgViewer/Viewer> #include <osgCompute/Memory> #in ...

  2. 关于python的类方法、实例方法和静态方法区别

    python的类方法需要在方法前面加装饰器:@classmethod ,静态方法是在方法前面加装饰器:@staticmethod. 类方法.类属性是属于类自身,属于类自身的命名空间,和实例方法.实例属 ...

  3. 非常简洁的js图片轮播

    <div id="tupian"></div><script>var jpg =new Array();jpg[0]="url(c.j ...

  4. 常量指针(const X*)和指针常量(X* const)

    const X* 类型的指针(指向常量的指针),此指针的地址是一个变量,是可以修改的:但其所指向的内容是常量,是不可以修改的. 例如: 1: char name[5] = "lisi&quo ...

  5. 【Linux】给Linux配置SNMP用户以及协议

    1 检查是否已经安装snmp的rpm包Ideploy:~ # rpm -aq | grep snmp libsnmp15-5.4.2.1-8.12.10.1 snmp-mibs-5.4.2.1-8.1 ...

  6. Oracle SQL 内置函数大全

    SQL中的单记录函数 1.ASCII 返回与指定的字符对应的十进制数;SQL> select ascii('A') A,ascii('a') a,ascii('0') zero,ascii(' ...

  7. DateUtils时间工具类探究

    首先声明一下,这个DateUtils工具类不是自己写的,而是在commons-lang-2.Xjar包或是commons-lang3-3.X.jar包中,具体在哪个jar包中,看程序具体添加了哪个版本 ...

  8. 8. Python自定义模块humansize

    我们在提取一个文件元信息的时候,经常会使用到获取元信息的size, 但是默认提取出来的是字节为单位计算的大小,我们需要转换成MB或者GB 或者TB的大小. 因此就需要使用到humansize这个模块, ...

  9. sublime3安装

    1.下载安装程序 http://c758482.r82.cf2.rackcdn.com/Sublime%20Text%20Build%203059%20Setup.exe 2.下载注册机 http:/ ...

  10. 转:java.io.IOException: Exceeeded maximum number of redirects: 5 解决版本

    Jmeter运行的时候出现的重定向超过n次的问题: When trying to test a Silverlight application, I get the below error. Has ...