uikit——UIView——content
来源:互联网 发布:简述什么是波士顿矩阵 编辑:程序博客网 时间:2024/06/07 11:50
content
@property(nonatomic) UIViewContentMode contentMode; // default is UIViewContentModeScaleToFill@property(nonatomic) CGRect contentStretch NS_DEPRECATED_IOS(3_0,6_0) __TVOS_PROHIBITED; // animatable. default is unit rectangle {{0,0} {1,1}}. Now deprecated: please use -[UIImage resizableImageWithCapInsets:] to achieve the same effect.
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,};
contentMode属性在UIImageView中应用非常多,用来设置UIImageView的显示方式,contentMode的解释如下:
- UIViewContentModeScaleToFill:content缩放,改变比例,content和view完全重叠
- UIViewContentModeScaleAspectFit:content缩放,不改变比例,wRatio = view.bounds.width / content.width,hRatio = view.bounds.height / content.height,取ratio = min(wRatio, hRatio),然后content.width = content.width * ratio,content.height = content.height * ratio,view.bounds的空余部分透明,content的中心位置和view的中心位置重叠
- UIViewContentModeScaleAspectFill:content缩放,不改变比例,wRatio = view.bounds.width / content.width,hRatio = view.bounds.height / content.height,取ratio = max(wRatio, hRatio),然后content.width = content.width * ratio,content.height = content.height * ratio,content的中心位置和view的中心位置重叠,content大于view.bounds的部分是否裁剪遵循clipsToBounds设置
- UIViewContentModeRedraw:content缩放,改变比例使content和view完全重叠,当bounds改变时重绘,即调用setNeedsDisplay
- UIViewContentModeCenter:content不缩放,content的中心位置和view的中心位置重叠
- UIViewContentModeTop:content不缩放,content的顶部中间位置和view的顶部中间位置重叠
- UIViewContentModeBottom:content不缩放,content的底部中间位置和view的底部中间位置重叠
- UIViewContentModeLeft:content不缩放,content的左边中间位置和view的左边中间位置重叠
- UIViewContentModeRight:content不缩放,content的右边中间位置和view的右边中间位置重叠
- UIViewContentModeTopLeft:content不缩放,content的左上角位置和view的左上角位置重叠
- UIViewContentModeTopRight:content不缩放,content的右上角位置和view的右上角位置重叠
- UIViewContentModeBottomLeft:content不缩放,content的左下角位置和view的左下角位置重叠
- UIViewContentModeBottomRight:content不缩放,content的右下角位置和view的右下角位置重叠
注:如果clipsToBounds为NO,在UI上显示的是最终的content范围,即使bounds范围小于content范围,如果clipsToBounds为YES,则content显示范围不会超出bounds
阅读全文
0 0
- uikit——UIView——content
- UIView——content
- uikit——UIView——drawing
- uikit——UIView——layout
- uikit——UIView——autoresizing
- uikit——UIView——tag
- uikit——UIView——event
- uikit——UIView——appearance
- uikit——UIView——resizing
- uikit——UIView——bounds frame
- uikit——UIView——view hierarchy
- uikit——UIView——tintColor tintAdjustmentMode
- uikit——UIView——layout定制
- uikit——Auto Layout——intrinsic content size
- uikit——Auto Layout——Readable Content Guide
- uikit——Auto Layout——Semantic Content
- uikit——Auto Layout——UIView——constraint
- uikit——Auto Layout——UIView——anchor
- 02_利用rand7() 产 生 rand10() 1~10(均匀概率)
- __attribute__ 用法
- 几种常用的最短路的求法
- 链表是否构成环、环的长度以及环的入口点的求法
- squid代理安装步骤
- uikit——UIView——content
- Jquery超简单遮罩层实现代码
- MySql 学习
- HDU-1051Wooden Sticks (贪心)
- HDU 4253 Two Famous Companies
- 剑指Offer——(35)数组中的逆序对
- zend studio7.2.1+破解教程
- 破解PowerDesigner16.5
- 2016腾讯笔试