iOS

iOS知识点总结——内容属性总结

2015-09-03  本文已影响0人  dibadalu

textAlignment

文字的水平方向的对齐方式

 NSTextAlignmentLeft      = 0, //左对齐
 NSTextAlignmentCenter    = 1, //居中对齐
 NSTextAlignmentRight     = 2, //右对齐

contentVerticalAlignment

内容的垂直方向的对齐方式

UIControlContentVerticalAlignmentCenter  = 0, //居中对齐
UIControlContentVerticalAlignmentTop     = 1, //顶部对齐
UIControlContentVerticalAlignmentBottom  = 2, //底部对齐

contentHorizontalAlignment

内容的水平方向的对齐方式

UIControlContentHorizontalAlignmentCenter = 0, //居中对齐
UIControlContentHorizontalAlignmentLeft   = 1, //左边对齐
UIControlContentHorizontalAlignmentRight  = 2, //右边对齐

contentMode

内容模式(控制内容的对齐方式)

/**
 规律:
 1.Scale: 图片会拉伸
 2.Aspect: 图片会保持原来的宽高比
 */
//前3个情况,图片都会拉伸
//(默认)拉伸图片至填充整个UIImgeView(图片的显示尺寸会跟UIImageView的尺寸一样)
UIViewContentModeScaleToFill,
//按照图片原来的宽高比进行伸缩,伸缩至适应整个UIImageView(图片的内容不会超出UIImageView的尺寸范围)
UIViewContentModeScaleAspectFit,
//按照图片原来的宽高比进行伸缩,伸缩至图片的宽度和UIImageView的宽度一样,或者图片的高度和UIImageView的高度一样
UIViewContentModeScaleAspectFill,
// 后面的所有情况,都会按照图片的原来尺寸显示,不会进行拉伸
UIViewContentModeRedraw,              // 当控件的尺寸改变了,就会重绘一次(重新调用setNeedsDisplay,就是调用drawRect:)
UIViewContentModeCenter,
UIViewContentModeTop,
UIViewContentModeBottom,
UIViewContentModeLeft,
UIViewContentModeRight,
UIViewContentModeTopLeft,
UIViewContentModeTopRight,
UIViewContentModeBottomLeft,
UIViewContentModeBottomRight,

如果有多个属性的作用冲突了,只有一个属性有效(就近原则)

上一篇 下一篇

猜你喜欢

热点阅读