cocoa touch——UIImageView

概述

UIImageView显示UIImage封装的图像

UIImageView

init

- (instancetype)initWithImage:(nullable UIImage *)image;
- (instancetype)initWithImage:(nullable UIImage *)image highlightedImage:(nullable UIImage *)highlightedImage NS_AVAILABLE_IOS(3_0);
注意:
  • UIImageVIew的bounds初始化为UIImage的size,取size时image优先级大于highlightedImage

state

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

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

appearance

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

// When tintColor is non-nil, any template images set on the image view will be colorized with that color.
// The tintColor is inherited through the superview hierarchy. See UIView for more information.
@property (null_resettable, nonatomic, strong) UIColor *tintColor NS_AVAILABLE_IOS(7_0);
注意:
  • 如果highlightedImage为nil,用image作为default highlightedImage,反之如果image为nil,不会用highlightedImage作为default image

animation

// these allow a set of images to be animated. the array may contain multiple copies of the same

@property (nullable, nonatomic, copy) NSArray<UIImage *> *animationImages; // The array must contain UIImages. Setting hides the single image. default is nil
@property (nullable, nonatomic, copy) NSArray<UIImage *> *highlightedAnimationImages NS_AVAILABLE_IOS(3_0); // The array must contain UIImages. Setting hides the single image. default is nil

@property (nonatomic) NSTimeInterval animationDuration;         // for one cycle of images. default is number of images * 1/30th of a second (i.e. 30 fps)
@property (nonatomic) NSInteger      animationRepeatCount;      // 0 means infinite (default is 0)

- (void)startAnimating;
- (void)stopAnimating;
- (BOOL)isAnimating;
注意:
  • 播放动画时,如果animationImages或highlightedAnimationImages中的UIImage是animated UIImage,只取第一张图片作为帧
  • 如果highlightedAnimationImages为nil,用animationImages作为default highlightedAnimationImages,反之如果animationImages为nil,不会用highlightedAnimationImages作为default animationImages
  • 播放动画时,如果对应的animationImages为nil(如果highlightedAnimationImages为nil,用animationImages作为default highlightedAnimationImages),播放无效果,用对应的image显示(如果highlightedImage为nil,用image作为default highlightedImage),即highlighted=YES时,显示顺序为highlightedAnimationImages->animationImages->highlightedImage->image,highlighted=NO时,显示顺序为animationImages->image
  • 调用startAnimating时,强制从第一帧从头开始播放,不会继续之前的播放进度
  • 如果当前处于动画中,此时修改animation状态(animationDuration,animationRepeatCount),立即停止播放动画(相当于调用stopAnimation),修改animation状态时不管新值与旧值是否相同
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值