FWZoomImageView
@interface FWZoomImageView : UIView <UIScrollViewDelegate>
支持缩放查看静态图片、live photo、视频的控件 默认显示完整图片或视频,可双击查看放大后的大小,再次双击恢复到初始大小。
支持通过修改 contentMode 来控制静态图片和 live photo 默认的显示模式,目前仅支持 UIViewContentModeCenter、UIViewContentModeScaleAspectFill、UIViewContentModeScaleAspectFit、UIViewContentModeScaleToFill(仅宽度拉伸),默认为 UIViewContentModeScaleAspectFit。注意这里的显示模式是基于 viewportRect 而言的而非整个 zoomImageView FWZoomImageView 提供最基础的图片预览和缩放功能,其他功能请通过继承来实现。
-
Undocumented
Declaration
Objective-C
@property(nonatomic, weak, nullable) id<FWZoomImageViewDelegate> delegate -
Undocumented
Declaration
Objective-C
@property(nonatomic, strong, readonly) UIScrollView *scrollView -
比如常见的上传头像预览界面中间有一个用于裁剪的方框,则 viewportRect 必须被设置为这个方框在 zoomImageView 坐标系内的 frame,否则拖拽图片或视频时无法正确限制它们的显示范围
Note
图片或视频的初始位置会位于 viewportRect 正中间Note
如果想要图片覆盖整个 viewportRect,将 contentMode 设置为 UIViewContentModeScaleAspectFill 即可 如果设置为 CGRectZero 则表示使用默认值,默认值为和整个 zoomImageView 一样大Declaration
Objective-C
@property (nonatomic) CGRect viewportRect; -
最大缩放比率,默认0根据contentMode自动计算
Declaration
Objective-C
@property (nonatomic) CGFloat maximumZoomScale; -
最小缩率比率,默认0根据contentMode自动计算
Declaration
Objective-C
@property (nonatomic) CGFloat minimumZoomScale; -
自定义最大缩放比率句柄,默认nil时根据contentMode自动计算
Declaration
Objective-C
@property (nonatomic, copy, nullable) CGFloat (^)(CGFloat, CGFloat) maximumZoomScaleBlock; -
最定义最小缩放比率句柄,默认nil时根据contentMode自动计算
Declaration
Objective-C
@property (nonatomic, copy, nullable) CGFloat (^)(CGFloat, CGFloat) minimumZoomScaleBlock; -
自定义双击放大比率句柄,默认nil时直接放大到最大比率
Declaration
Objective-C
@property (nonatomic, copy, nullable) CGFloat (^) (UIScrollView *_Nonnull __strong) zoomInScaleBlock; -
Undocumented
Declaration
Objective-C
@property(nonatomic, copy, nullable) NSObject<NSCopying> *reusedIdentifier -
设置当前要显示的图片,会把 livePhoto/video 相关内容清空,因此注意不要直接通过 imageView.image 来设置图片。
Declaration
Objective-C
@property (nonatomic, weak, nullable) UIImage *image; -
用于显示图片的 UIImageView,注意不要通过 imageView.image 来设置图片,请使用 image 属性。
Declaration
Objective-C
@property (nonatomic, strong, readonly) UIImageView *_Nonnull imageView; -
设置当前要显示的 Live Photo,会把 image/video 相关内容清空,因此注意不要直接通过 livePhotoView.livePhoto 来设置
Declaration
Objective-C
@property (nonatomic, weak, nullable) PHLivePhoto *livePhoto; -
用于显示 Live Photo 的 view,仅在 iOS 9.1 及以后才有效
Declaration
Objective-C
@property (nonatomic, strong, readonly) PHLivePhotoView *_Nonnull livePhotoView; -
设置当前要显示的 video ,会把 image/livePhoto 相关内容清空,因此注意不要直接通过 videoPlayerLayer 来设置
Declaration
Objective-C
@property (nonatomic, weak, nullable) AVPlayerItem *videoPlayerItem; -
用于显示 video 的 layer
Declaration
Objective-C
@property (nonatomic, strong, readonly) AVPlayerLayer *_Nonnull videoPlayerLayer; -
获取当前正在显示的图片/视频的容器
Declaration
Objective-C
@property (nonatomic, weak, readonly, nullable) __kindof UIView *contentView; -
是否播放video时显示底部的工具栏,默认NO
Declaration
Objective-C
@property (nonatomic) BOOL showsVideoToolbar; -
Undocumented
Declaration
Objective-C
@property(nonatomic, strong, readonly) FWZoomImageVideoToolbar *videoToolbar -
Undocumented
Declaration
Objective-C
@property(nonatomic, assign) UIEdgeInsets videoToolbarMargins -
Undocumented
Declaration
Objective-C
@property(nonatomic, strong, readonly) UIButton *videoPlayButton -
Undocumented
Declaration
Objective-C
@property(nonatomic, strong) UIImage *videoPlayButtonImage -
Undocumented
Declaration
Objective-C
@property(nonatomic, assign) BOOL showsVideoCloseButton -
Undocumented
Declaration
Objective-C
@property(nonatomic, strong, readonly) UIButton *videoCloseButton -
Undocumented
Declaration
Objective-C
@property(nonatomic, strong) UIImage *videoCloseButtonImage -
Undocumented
Declaration
Objective-C
@property(nonatomic, copy, nullable) CGPoint (^videoCloseButtonCenter -
Undocumented
Declaration
Objective-C
@property(nonatomic, strong) UIView<FWProgressViewPlugin> *progressView -
Undocumented
Declaration
Objective-C
@property(nonatomic, assign) CGFloat progress -
是否正在播放视频
Declaration
Objective-C
@property (nonatomic, readonly) BOOL isPlayingVideo; -
开始视频播放
Declaration
Objective-C
- (void)playVideo; -
暂停视频播放
Declaration
Objective-C
- (void)pauseVideo; -
停止视频播放,将播放状态重置到初始状态
Declaration
Objective-C
- (void)endPlayingVideo; -
获取当前正在显示的图片/视频在整个 FWZoomImageView 坐标系里的 rect(会按照当前的缩放状态来计算)
Declaration
Objective-C
- (CGRect)contentViewRect; -
重置图片或视频的大小,使用的场景例如:相册控件里放大当前图片、划到下一张、再回来,当前的图片或视频应该恢复到原来大小。注意子类重写需要调一下super
Declaration
Objective-C
- (void)revertZooming; -
快速设置图片URL,参数支持UIImage|PHLivePhoto|AVPlayerItem|NSURL|NSString类型
Declaration
Objective-C
- (void)setImageURL:(nullable id)imageURL; -
快速设置图片URL,支持占位图和完成回调,参数支持UIImage|PHLivePhoto|AVPlayerItem|NSURL|NSString类型
Declaration
Objective-C
- (void)setImageURL:(nullable id)imageURL placeholderImage:(nullable UIImage *)placeholderImage completion:(nullable void (^)(UIImage *_Nullable __strong))completion;
FWZoomImageView Class Reference