码迷,mamicode.com
首页 > 其他好文 > 详细

UIImageView控件

时间:2015-08-12 18:56:23      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:

  UIImageView是用于显示图像的,在iOS开发中,我们无需专门去写什么代码,不需要检查设备的类型,只需要把1x、2x、3x的图像添加到项目中,图像视图会自动的在正确的时间加载正确的图像。

  (1)UIImageView的创建及简单用法

    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"banner01"]];

    imageView.backgroundColor = [UIColor lightGrayColor];

    imageView.frame = CGRectMake(20, 20, 200, 300);

    [self.view addSubview:imageView];

  (2)contentMode属性

typedef NS_ENUM(NSInteger, UIViewContentMode) {

    UIViewContentModeScaleToFill,    //图像填充整个imageView的大小

    UIViewContentModeScaleAspectFit,     //图像保持原宽高比放在视图中间

    UIViewContentModeScaleAspectFill,    //图像保持原宽高比扩充放在视图的中间点上

    UIViewContentModeRedraw,               // redraw on bounds change (calls -setNeedsDisplay)

    UIViewContentModeCenter,                //图像水平居中,竖直居中,图片保持原大小 

    UIViewContentModeTop,         //图像水平居中,竖直居上,图片保持原大小

    UIViewContentModeBottom,       //图像水平居中,竖直居下,图片保持原大小

    UIViewContentModeLeft,        //图像水平居左,竖直居中,图片保持原大小

    UIViewContentModeRight,       //图像水平居右,竖直居中,图片保持原大小

    UIViewContentModeTopLeft,      //图像水平居左,竖直居上,图片保持原大小

    UIViewContentModeTopRight,    //图像水平居左,竖直居上,图片保持原大小

    UIViewContentModeBottomLeft,    //图像水平居中,竖直居下,图片保持原大小

    UIViewContentModeBottomRight,  //图像水平居中,竖直居下,图片保持原大小

};

  (3)

  (4)

  (5)

  (6)

  (7)

  (8)

  (9)

UIImageView控件

标签:

原文地址:http://www.cnblogs.com/yyt-hehe-yyt/p/4725140.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!