您的位置:首页 > 产品设计 > UI/UE

iOS学习(UIImageView)

2015-07-31 22:20 363 查看
5.UIImageView是展示图片的一种控件

1).初始化

UIImageView *imageView = [[UIImageView
alloc]
init];
    2).调整尺寸大小

imageView.frame =
CGRectMake(0,
0, self.view.frame.size.width,
self.view.frame.size.width);
    3).调整背景颜色
imageView.backgroundColor = [UIColor
whiteColor];

    4).调整图片在的位置
imageView.center =
self.view.center;(这里的view是从windows里获取的)
    5).获取图片到imageView
 imageView.image = image(image是我们住呢比好的图片对象)

6).uiview的属性,设置为yes的时候超出部分,不予以显示
imageView.clipsToBounds =
YES;

7).UIImageView几种填充模式

            <1>UIViewContentModeScaleToFill 
拉伸image使其充满UIImageView

     <2>UIViewContentModeScaleAspectFill
拉伸image使其不变形,并且充满UIImageView

     <3>UIViewContentModeScaleAspectFit
拉伸imgage使其不变形,并且完全显示在UIImageView中

如果有Scale属性,图片都会被拉伸

8).UIImageView和button一样都有触发事件

imageView.userInteractionEnabled =
YES;(打开imageview的用户交互)

 UITapGestureRecognizer *tap = [[UITapGestureRecognizer
alloc]
initWithTarget:self
action:@selector(imageViewTapped:)];

[imageView addGestureRecognizer:tap];(点击手势)

    ;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: