UIImageView图片视图的基本概念和使用方法

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

Author:hmjiangqq

Email:[email protected]

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
时间: 2024-08-23 19:27:20

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

iOS 图片视图UIImageView小记

1关于在图片视图上添加按钮后,点击按钮没反应的问题 一般情况下是由于图片视图没有开启用户交互导致的,也有可能是按钮视图被其他视图覆盖了或者超出范围 现在是开启用户交互的代码,你要手动开启,默认是关闭的 yourImageView.userInteractionEnabled = YES

iOS:UIImageView图像视图控件

UIImageView:图像视图控件: 它是UIView的子类,因此也是视图控件,可以用来显示图像.因为它具有帧动画属性和操作方法,因此可以用来制作动画,其实动画就是很短的时间内,执行显示连续的很多张图片,人肉眼无法处分,使人看起来仿佛图像在动似的.例如典型的实例:汤姆猫实例 @interface UIImageView : UIView { @property(nonatomic,retain) UIImage *image;    //图像 @property(nonatomic,retai

ObjectiveC:UIImageView图像视图控件

UIImageView:图像视图控件: 它是UIView的子类,因此也是视图控件,可以用来显示图像.因为它具有帧动画属性和操作方法,因此可以用来制作动画,其实动画就是很短的时间内,执行显示连续的很多张图片,人肉眼无法处分,使人看起来仿佛图像在动似的.例如典型的实例:汤姆猫实例 @interface UIImageView : UIView { @property(nonatomic,retain) UIImage *image;    //图像 @property(nonatomic,retai

154在屏幕中绘图时设置透明度(扩展知识:为图片视图添加点击手势识别器,来实现点击事件操作)

一张图片,通过混合模式绘制后,能得到不同效果的图片. 这里的示例仅是测试效果:实际上可以通过不同程度的混合模式绘制,来得到符合需求的效果. 效果如下: ViewController.h 1 #import <UIKit/UIKit.h> 2 3 @interface ViewController : UIViewController 4 @property (strong, nonatomic) UIImageView *imgVBlend; 5 @property (strong, nona

02-常见控件:ImageView(图片视图)、slider(滑动器)、switch(开关)使用

效果图:       通过点击设置 将显示如第二张图所示                            第三张为项目目录文件 供参考              主要代码: // // WHBLAPViewController.h // 04-whblap查看器 // // Created by whblap on 14-6-6. // Copyright (c) 2014年 whblap. All rights reserved. // #import <UIKit/UIKit.h>

Android——图片视图(ImageView)、状态开关按钮(ToggleButton)、时钟

xml <?xml version="1.0" encoding="utf-8"?> <!--滚动视图--> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_pare

PLSQL_Material View物化视图的基本概念和用法(概念)

2014-06-08 BaoXinjian 1. 用法 物化视图是包括一个查询结果的数据库对象,它是远程数据的的本地副本,或者用来生成基于数据表求和的汇总表. 物化视图存储基于远程表的数据,也可以称为快照.对于复制,物化视图允许你在本地维护远程数据的副本,这些副本是只读的. 如果你想修改本地副本,必须用高级复制的功能.当你想从一个表或视图中抽取数据时,你可以用从物化视图中抽取. 对于数据仓库,创建的物化视图通常情况下是聚合视图,单一表聚合视图和连接视图. 实现两个数据库之间的数据同步,可以存在时

图片视图、图片按钮和单选按钮

1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:tools="http://schemas.android.com/tools" 4 android:layout_width="match_parent

阅读《Android 从入门到精通》(20)——图片视图

图片视图(ImageView) ImageView 类属于 android.Widget 包并且继承于 android.widget.View 类,派生了 ImageButton 和 ZoomButton 等子类,主要用于对图片作相关处理.可以通过 setImageBitmap 方法或 setImageResource(int) 方法设置图片资源,或者通过 android:src 属性指定. ImageView 类方法 ImageView 示例 完整工程:http://download.csdn