imageView.frame
=
CGRectMake(0, 0, 320,460);
imageView.bounds = CGRectMake(100, 100,160, 230);
执行之后,这个
imageView 的位置和大小是(80, 115, 160, 230)。
3、contentMode 属性:
这个属性是用来设置图片的显示方式,如居中、居右,是否缩放等,有一下几个常量可供设
定:
UIViewContentModeScaleToFill
UIViewContentModeScaleAspectFit
UIViewContentModeScaleAspectFill
UIViewContentModeRedraw
UIViewContentModeCenter
UIViewContentModeTop
UIViewContentModeBottom
UIViewContentModeLeft
UIViewContentModeRight
UIViewContentModeTopLeft
UIViewContentModeTopRight
UIViewContentModeBottomLeft
UIViewContentModeBottomRight
注意以上几个常量,凡是没有带
Scale 的,当图片尺寸超过 ImageView 尺寸时,只有部分
显 示 在
ImageView 中 。 UIViewContentModeScaleToFill 属 性 会 导 致 图 片 变 形 。
UIViewContentModeScaleAspectFit 会保证图片比例不变,而且全部显示在 ImageView 中,
这意味着
ImageView 会有部分空白。UIViewContentModeScaleAspectFill 也会证图片比例不
变,但是是填充整个
ImageView 的,可能只有部分图片显示出来。
前三个效果如下图:
找软件资料,就到一览软件文库