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. Hibernate配置文件的hbm2ddl.auto属性

    今天遇到一个有意思的问题,我目前做的一个网站采用Spring MVC + Spring + Hibernate的架构,我通过页面插入了一些数据到数据库,可是每次重启tomcat之后,数据都莫名其妙地丢 ...

  2. HDU 2614 Beat(DFS)

    题目链接 Problem Description Zty is a man that always full of enthusiasm. He wants to solve every kind o ...

  3. ZUFE 1035 字符宽度编码(字符串)

    Time Limit: 1 Sec  Memory Limit: 128 MB Description 你的任务是编写一个程序实现简单的字符宽度编码方法.规则如下:将任何2~9个相同字符的序列编码成2 ...

  4. ORA-39070

    背景介绍: 项目以前建立的库,表空间文件文件比较多,问了一下dba,了解到表空间建立很多没有带来优惠(都在一块磁盘上),效率也不会提高:现在要进行新库的迁移(目前使用的是asm磁盘组rac集群),正好 ...

  5. perl Socket接收超时设置

    一般来说, IO::Socket::INET里的Timeout设置是对于conncet的 如果你想设置recv接收超时, 可以这样设置: usr Socket: ...... , )); #注意这里p ...

  6. MySQL5.7以上开启binlog

    在my.cnf的mysqld下加入: server_id = 0 log_bin=/harddisk/mysql_data/mysql_binlog/mysql-bin binlog_format   ...

  7. json处理三部曲之第一曲:利用json-lib-xxx.jar处理json

    json-lib-xxx.jar包必需5个依赖包(实测): ezmorph-xxx.jar commons-lang-xxx.jar commons-beanutils-xxx.jar commons ...

  8. NSTimer 销毁问题 和 iOS中控制器的释放问题

    俗话说的好,前人栽树后人乘凉,最近看了很多博文,不少博文提到了NSTimer的销毁问题, 之前我都没怎么注意,现在对照着文章一一实践发现坑还真不少.下面是我读到的几篇博文分享给大家 @啸笑天的NSTi ...

  9. 制作、烧写根文件系统,使用NFS,编译使用驱动程序

    制作YAFFS2.JFFS2文件系统映象文件制作文件系统映象非常简单.① 制作YAFFS2文件系统映象文件对于YAFFS2,要用到mkyaffs2image工具,它在/work/linux/tools ...

  10. leetcode409

    Given a string which consists of lowercase or uppercase letters, find the length of the longest pali ...