zoukankan      html  css  js  c++  java
  • UIImageView图片视图的基本概念和使用方法

     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
  • 相关阅读:
    使用ngx_lua构建高并发应用(1)
    nginx+lua项目学习
    学习乱
    if---(switch-case)语句初步学习总结
    数据类型转换
    总结:C#变量,占位符等相关知识
    学习随笔
    开始我的.NET的学习旅程
    Python 网络爬虫 008 (编程) 通过ID索引号遍历目标网页里链接的所有网页
    Python 网络爬虫 007 (编程) 通过网站地图爬取目标站点的所有网页
  • 原文地址:https://www.cnblogs.com/Free-Thinker/p/4974072.html
Copyright © 2011-2022 走看看