UIImageView常用属性和方法

本文深入解析iOS开发中图片组件的关键属性与常用方法,包括默认图片、高亮图片、交互状态、动画播放等核心概念,提供丰富的实例帮助开发者熟练掌握并运用这些特性,提升应用的用户体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、常用属性

1、image: default is nil。图片属性

2、highlightedImage: default is nil。高亮状态图片属性


3、userInteractionEnabled: default is NO。用户是否可以交互属性


4、highlighted: default is NO。判断图片是否是高亮状态


these allow a set of images to be animated. the array may contain multiple copies of the same(下面属性允许图像组动画,该数组内可能包含相同的多个副本)

5、animationImages: The array must contain UIImages. Setting hides the single image. default is nil。该数组当中必须包含多张图片,设置单张图片将被隐藏,默认 nil

@property (nullable, nonatomic, copy) NSArray<UIImage *> *animationImages;


6、highlightedAnimationImages: The array must contain UIImages. Setting hides the single image. default is nil.高亮状态的组动画。


7、animationDuration: for one cycle of images. default is number of images * 1/30th of a second (i.e. 30 fps)。动画播放时间,对于一个周期的图像,默认的是图像是一秒30帧。

@property (nonatomic) NSTimeInterval animationDuration;


8、animationRepeatCount: 0 means infinite (default is 0)。动画循环次数。0意味着无限(默认0)。

@property (nonatomic) NSInteger      animationRepeatCount;


9、tintColor: 给控件内子视图设置颜色。详细信息请见 UIImage类属性。


10、focusedFrameGuide: if adjustsImageWhenAncestorFocused is set, the image view may display its image in a larger frame when focused.this layout guide can be used to align other elements with the image view's focused frame.如果设置了adjustsImageWhenAncestorFocused,图像视图可以在一个更大的 frame 中显示其图片的焦点。这个布局指南,可用于将其他元素与图像视图的聚焦帧对齐。

@property(readonly,strong) UILayoutGuide *focusedFrameGuide;



二、常用方法

1、initWithImage:: 构造方法,在初始化对象时直接进行默认图片进行赋值。

- (instancetype)initWithImage: (nullable UIImage *)image;


2、initWithImage:highlightedImage:: 构造方法,在初始化对象时直接给默认和高亮图片进行赋值

- (instancetype)initWithImage: (nullable UIImage *)image highlightedImage: (nullable UIImage *)highlightedImage;


3、startAnimating:: 开始动画

- (void)startAnimating;


4、stopAnimating:: 结束动画

- (void)stopAnimating;


5、isAnimating:: 动画中

- (BOOL)isAnimating;


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值