UIImageView的contentMode属性
UIViewContentMode 都有哪些值:
typedef NS_ENUM(NSInteger, UIViewContentMode) {
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,
};
默认值是 0,也就是:
UIViewContentModeScaleToFill
一个个来理解下吧:
- UIViewContentModeScaleToFill:表示完全填充在 frame 里 不按比例来。
- UIViewContentModeScaleAspectFit:保持比例,都在 frame 内。
- UIViewContentModeScaleAspectFill:保持比例,填满但 frame 外也有。
- UIViewContentModeRedraw:每次设置或更改frame的时候自动调用drawRect.
其他的是相似的,好理解:
- UIViewContentModeCenter:这个 image 的中心与 frame 的中心重合。
- UIViewContentModeTop:这个 image 的上边缘与 frame 的上边缘重合。
- UIViewContentModeBottom:这个 image 的下边缘与 frame 的下边缘重合。
- UIViewContentModeLeft:这个 image 的左边缘与 frame 的左边缘重合。
- UIViewContentModeRight:这个 image 的右边缘与 frame 的右边缘重合。
- UIViewContentModeTopLeft:类似。
- UIViewContentModeTopRight:类似。
- UIViewContentModeBottomLeft:类似。
- UIViewContentModeBottomRight:类似。
经常用到的:1.比如长图的显示 按一定的比例只显示中间的一部分 其他的裁剪掉
self.imageView.contentMode = UIViewContentModeScaleAspectFill;
self.imageView.clipsToBounds = YES;
UIImageView的contentMode属性的更多相关文章
- [BS-24] UIImageView的contentMode属性
UIImageView的contentMode属性 所有的UIView都有个contentMode属性,UIImageView继承自UIView,我们在使用UIImageView时,经常要考虑这些 ...
- UIImageView 的contentMode属性应用
UIImageView 的contentMode这个属性是用来设置图片的显示方式,如居中.居右,是否缩放等,有以下几个常量可供设定:UIViewContentModeScaleToFillUIView ...
- UIImageView 的contentMode属性 浅析
UIImageView 的contentMode这个属性是用来设置图片的显示方式,如居中.居右,是否缩放等,有以下几个常量可供设定:UIViewContentModeScaleToFillUIView ...
- iOS开发-UIImageView的contentMode属性
UIImageView 的contentMode这个属性是用来设置图片的显示方式,如居中.居右,是否缩放等,有以下几个常量可供设定:UIViewContentModeScaleToFillUIView ...
- UIImageView 的contentMode属性
UIViewContentModeScaleToFill UIViewContentModeScaleAspectFit UIViewContentModeScaleAspectFill UIView ...
- IOS UIImageView的contentMode属性
红框表示imageView的frame,下面的图片是原图大小UIViewContentModeScaleToFill, 默认,对图片进行拉伸处理(不是按比例),是充满bouns UIVie ...
- 重写UIImageView的image属性
重写UIImageView的image属性 效果: 当你重写了UIImageView的image属性后你就会对UIImageView怎么显示图片了如指掌了:) 源码: UIImageView.h + ...
- 通过 CALayer 修改 UIImageView 的界面属性
界面属性的修改是每一个开发者必须知道的,为什么我就记不住呢, shit, 又耽误了时间,为了防止再找不到,特把一些常用的 CALayer属性记在这里,顺便分享 1.设置阴影 1 imageView.l ...
- 0119——UIImageView的一些属性 和 简单动画实现
1.contentMode view.contentMode = UIViewContentModeScaleAspectFill; 2.是否实现触摸 3.简单实现动画 图片的名字为campFire0 ...
随机推荐
- Java数组遍历输出
在Java中,如何将字符串数组写入输出控制台? 以下示例演示了通过循环将数组的元素写入输出控制台. package com.yiibai; public class ArrayOutput { pub ...
- (转)Live555中RTSPClient分析
有RTSPServer,当然就要有RTSPClient. 如果按照Server端的架构,想一下Client端各部分的组成可能是这样:因为要连接RTSP server,所以RTSPClient要有TCP ...
- [Learn AF3]第四章 App framework组件之Button
Button 组件名称:Button 是否js控件:否 使用说明:如果说panel组件是af3的“核心(heart of the ui)”,那么Button就是af中的五虎上将之 ...
- jQuery实现ToolTip元素定位显示功能示例
记录下,以备将来用到 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// ...
- Oracle-10.2.0.1,打补丁10.2.0.5:在 debian 版本4【不含4】以上,及 ubuntu 7.04【不含7.04】以上都可以安装!
如题. todo 特殊的:ubuntu 16.04 LTS 版本 无法安装成功,原因待查找!!! 最近测试练习安装linux x64上的 oracle10.2.0.5, 都要吐了.
- jenkins 神奇变量
Hudson自己设置的一些环境变量可用于通过Hudson来执行shell脚本.Windows批处理文件和Ant文件,他们包括 Hudson设置环境变量 当一个Hudson作业执行时,它会设置一些环境变 ...
- 使用php用IE打开指定网页
$cmd = '"C:\Program Files\Internet Explorer\iexplore.exe" http://www.baidu.com'; exec($cmd ...
- Android开发学习笔记-自定义控件的属性
若想让自定义控件变得更加方便灵活,则就需要对控件进行定义属性,使其用起来更方便. 下面是自定义控件属性的方法 1.添加attrs.xml,内容格式样式可以参考sdk\platforms\android ...
- 让你的应用支持新iPad的Retina显示屏
一.应用图片标准iOS控件里的图片资源,苹果已经做了相应的升级,我们需要操心的是应用自己的图片资源.就像当初为了支持iPhone 4而制作的@2x高分辨率版本(译者:以下简称高分)图片一样,我们要为i ...
- Mybatis -- 批量添加 -- insertBatch
啦啦啦 ---------------InsertBatch Class : Dao /** * 批量插入perfEnvirons * * @author Liang * * 2017年4月25日 * ...