UIViewContentMode各类型效果
2015-12-15 09:37
716 查看
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,
};
注意以上几个常量,凡是没有带Scale的,当图片尺寸超过
ImageView尺寸时,只有部分显示在ImageView中。UIViewContentModeScaleToFill属性会导致图片变形。UIViewContentModeScaleAspectFit会保证图片比例不变,而且全部显示在ImageView中,这意味着ImageView会有部分空白。UIViewContentModeScaleAspectFill也会证图片比例不变,但是是填充整个ImageView的,可能只有部分图片显示出来。
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,
};
注意以上几个常量,凡是没有带Scale的,当图片尺寸超过
ImageView尺寸时,只有部分显示在ImageView中。UIViewContentModeScaleToFill属性会导致图片变形。UIViewContentModeScaleAspectFit会保证图片比例不变,而且全部显示在ImageView中,这意味着ImageView会有部分空白。UIViewContentModeScaleAspectFill也会证图片比例不变,但是是填充整个ImageView的,可能只有部分图片显示出来。
![](http://images2015.cnblogs.com/blog/713135/201512/713135-20151215093644771-230820956.png)
相关文章推荐
- Querying JSON
- ORA-12520: TNS:listener could not find available handler for requested type of server
- 详解iOS开发中UItableview控件的数据刷新功能的实现
- Arduino - 改装车库门,增设手机蓝牙控制功能
- ios UITableview 刷新某一个cell 或 section
- 《UIPageControl 的创建和 自定义和引导页的使用》
- iOS9 新增 UIStackView 官方文档翻译
- iOS UIScrollView 没有从顶部开始滑动
- Arduino - Micro SD卡 读写
- 298. Binary Tree Longest Consecutive Sequence
- iOS之UI--使用SWRevealViewController实现侧边菜单功能详解实例
- setProjectionMap@SQLiteQueryBuilder使用简记
- Android Service更新UI的方法之AIDL
- HDU 1242 Rescue
- UILabel的富文本设置
- UICollection 找不同--小游戏
- push to bluemix and get wrong
- Android开源之仿微信UI
- RequireJS笔记
- 认识String、StringBuilder、StringBuffer的区别