首页 > 其他 > 详细

UIImageView控件

时间:2015-08-12 18:55:32      阅读:108      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!