温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

IOS学习笔记(十)之UIImageView图片视图的基本概念和使用方法

发布时间:2020-07-04 17:44:02 来源:网络 阅读:645 作者:jiangqq900826 栏目:移动开发

 IOS学习笔记(十)之UIImageView图片视图的基本概念和使用方法

     Author:hmjiangqq

     Email:jiangqqlmj@163.com

UIImageView:

作用:专门用于显示图片

首先看下官方的解说:

 An p_w_picpath view object provides a view-based container for displaying either a single p_w_picpath or for animating a series of p_w_picpaths. For animating the p_w_picpaths, 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 p_w_picpaths, the actual behavior is based on the properties of the p_w_picpath and the view. If either of the p_w_picpath’s leftCapWidth ortopCapHeight properties   are non-zero, then the p_w_picpath is stretched according to the values in those properties. Otherwise, the p_w_picpath is scaled, sized to fit, or positioned in the p_w_picpath view according to the contentMode property   of the view. It is recommended (but not required) that you use p_w_picpaths that are all the same size. If the p_w_picpaths are different sizes, each will be adjusted to fit separately based on that mode.

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

常用属性和方法:
IOS学习笔记(十)之UIImageView图片视图的基本概念和使用方法

实例代码:

//创建图片视图
//创建图片视图
UIImageView *p_w_picpathview=[[UIImageView  alloc]initWithFrame:CGRectMake(140, 100, 45, 45)];
//设置高亮
p_w_picpathview.highlighted=YES;
//设置图片
p_w_picpathview.p_w_picpath=[UIImage p_w_picpathNamed:@"notification_icon"];
//设置高亮图片
p_w_picpathview.highlightedImage=[UIImage p_w_picpathNamed:@"notification_icon"];
[self.window addSubview:p_w_picpathview];

- (id)initWithImage:(UIImage *)p_w_picpath;    //初始化一张图片
- (id)initWithImage:(UIImage *)p_w_picpath highlightedImage:(UIImage *)highlightedImage NS_AVAILABLE_IOS(3_0);
//初始化 加入一张高亮图片与本身图片
//默认图片
@property(nonatomic,retain) UIImage *p_w_picpath;                                                     // 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


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI