IOS学习笔记(十)之UIImageView图片视图的基本概念和使用方法(博客地址: http://blog.csdn.net/developer_jiangqq )

Author:hmjiangqq

Email:jiangqqlmj@163.com

UIImageView:

作用:专门用于显示图片

首先看下官方的解说:

An image view object provides a view-based container for displaying either a single image or for animating a series of images. For animating the images, the  UIImageView  class provides controls to set the duration and frequency of the animation. You can also start and stop the animation freely.

When a  UIImageView  object displays one of its images, the actual behavior is based on the properties of the image and the view. If either of the image’s  leftCapWidth  or topCapHeight  properties are non-zero, then the image is stretched according to the values in those properties. Otherwise, the image is scaled, sized to fit, or positioned in the image view according to the  contentMode  property of the view. It is recommended (but not required) that you use images that are all the same size. If the images are different sizes, each will be adjusted to fit separately based on that mode.

All images associated with a  UIImageView  object should use the same  scale . If your application uses images with different scales, they may render incorrectly.

常用属性和方法:

实例代码:

//创建图片视图
UIImageView *imageview=[[UIImageView alloc]initWithFrame:CGRectMake(140, 100, 45, 45)];
//设置高亮
imageview.highlighted=YES;
//设置图片
imageview.image=[UIImage imageNamed:@"notification_icon"];
//设置高亮图片
imageview.highlightedImage=[UIImage imageNamed:@"notification_icon"];
[self.window addSubview:imageview];
- (id)initWithImage:(UIImage *)image;    //初始化一张图片

- (id)initWithImage:(UIImage *)image highlightedImage:(UIImage *)highlightedImage NS_AVAILABLE_IOS(3_0);

//初始化 加入一张高亮图片与本身图片

//默认图片

@property(nonatomic,retain) UIImage *image;                                                     // default is nil

//高亮图片

@property(nonatomic,retain) UIImage *highlightedImage NS_AVAILABLE_IOS(3_0);      // default is nil

@property(nonatomic,getter=isUserInteractionEnabled) BOOL userInteractionEnabled;               // default is NO

//设置为YES 用户才可以进行点击

//设置为YES 图片高亮显示

@property(nonatomic,getter=isHighlighted) BOOL highlighted NS_AVAILABLE_IOS(3_0); // default is NO

UIImageView图片视图的基本概念和使用方法的更多相关文章

  1. iOS:UIImageView图像视图控件

    UIImageView:图像视图控件:    它是UIView的子类,因此也是视图控件,可以用来显示图像.因为它具有帧动画属性和操作方法,因此可以用来制作动画,其实动画就是很短的时间内,执行显示连续的 ...

  2. Android——滚动视图(ScrollView)图片视图(ImageView)、状态开关按钮(ToggleButton)、时钟

    xml <?xml version="1.0" encoding="utf-8"?> <!--滚动视图--> <ScrollVie ...

  3. php如何防止图片盗用/盗链的两种方法(转)

    图片防盗链有什么用? 防止其它网站盗用你的图片,浪费你宝贵的流量.本文章向大家介绍php防止图片盗用/盗链的两种方法 Apache图片重定向方法 设置images目录不充许http访问 Apache服 ...

  4. php如何防止图片盗用/盗链的两种方法

    如今的互联网,采集网站非常多,很多网站都喜欢盗链/盗用别人网站的图片,这样不仅侵犯网权,还导致被盗链的网站消耗大量的流量,给服务器造成比较大的压力,本文章向大家介绍php如何防止图片盗用/盗链的两种方 ...

  5. 图片懒加载插件lazyload使用方法

    图片懒加载插件lazyload使用方法 一.如何使用: Lazy Load 依赖于 jQuery.引入文件 <script type="text/javascript" sr ...

  6. MVC中视图View向控制器传值的方法

    MVC中视图View向控制器传值的方法步骤如下: 1.index页面: 页面中只需要一个触发事件的按钮

  7. AWS Python SDK boto3中的基本概念与使用方法

    最近在用boto3编写AWS的lamda函数,学习到了boto3中的一些基本概念与使用方法.在此进行总结. 1. boto3提供了两个级别的接口来访问AWS服务:High Level的Resource ...

  8. ASP图片格式与base64数据互转方法

    ASP图片格式与base64数据相互转换的方法,经常用于处理表单中存储有base64字符串格式的图片. 获取到base64数据,转换成图片 <% Subfolder=year(now)& ...

  9. <转载>CSS解决图片过大撑破DIV的方法

    DIV+CSS网页内容中如果插入大于DIV层宽度显示,过大的图片将会撑破网页宽度显示从而网页严重变形,您是否遇到过?这里DIVCSS5给大家介绍几种解决图片撑破撑开网页DIV层方法. 图片撑破宽度解决 ...

随机推荐

  1. hdu 5652 India and China Origins 二分+bfs

    题目链接 给一个图, 由01组成, 1不能走. 给q个操作, 每个操作将一个点变为1, 问至少多少个操作之后, 图的上方和下方不联通. 二分操作, 然后bfs判联通就好了. #include < ...

  2. zookeeper参考

        ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,它是一个为分布式应用提供一致性服务的软件,提供的功能包括:配置维护.名字服务.分布式同步.组服务等.     我需要运行几个 ...

  3. Robot Framework中DatabaseLibrary应用

    DatabaseLibrary: 在RF的官网上,有DatabaseLibrary的下载链接,DatabaseLibrary有2个版本,Python和Java版.本人使用的是Python版本. 1.下 ...

  4. 强制删除正在连接的Oracle用户,以删除SDE用户为例

    . 有时候想强制删除一个已经连接的Oracle用户,不能直接删除,可以用Kill会话信息. 比如今天想删除一个被连接的SDE用户,可以用以下方法删除一个“正在被连接”的用户. 1.查看所有用户的会话信 ...

  5. Oracle EBS-SQL (INV-1):库存货位列表.sql

    select inventory_location_id, organization_id, description, subinventory_code, segment1 inventory_lo ...

  6. 解决Qt程序发布时中文乱码问题(通过QApplication.addLibraryPath加载QTextCodec插件)

    Qt程序的文字编码,是通过插件来解决的,所以我们发布的时候需要把相应的插件也发布出去,在开发者电脑上程序会自动从插件目录加载到插件,但是如果发布给别的电脑使用,需要手动指定插件路径,如下所示: int ...

  7. Windows Azure Web Role 的 IIS 重置

     如果您是一名 Web开发人员,您很可能使用过"简单快捷"的iisreset命令重置运行不正常的 IIS主机.这种方法通常在经典的 Windows Server VM上非常有效 ...

  8. Android中ViewStub组件使用

    1. 概述: ViewStub组件和<include>标签的作用类似,主要是为了提高布局的重用性,及布局的模块化.它们之间最大的差别是,ViewStub中的布局不会随着它所在布局的渲染而渲 ...

  9. [Leetcode][Python]22: Generate Parentheses

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 22: Generate Parentheseshttps://oj.leet ...

  10. 04737_C++程序设计_第9章_运算符重载及流类库

    例9.1 完整实现str类的例子. #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> ...