FWImagePreviewView
@interface FWImagePreviewView
: UIView <UICollectionViewDataSource, UICollectionViewDelegateFlowLayout,
FWZoomImageViewDelegate>
查看图片的控件,支持横向滚动、放大缩小、loading 及错误语展示,内部使用 UICollectionView 实现横向滚动及 cell 复用,因此与其他普通的 UICollectionView 一样,也可使用 reloadData、collectionViewLayout 等常用方法。
使用方式:
- 使用 initWithFrame: 或 init 方法初始化。
- 设置 delegate。
- 在 delegate 的 numberOfImagesInImagePreviewView: 方法里返回图片总数。
- 在 delegate 的 imagePreviewView:renderZoomImageView:atIndex: 方法里为 zoomImageView.image 设置图片,如果需要,也可调用 [zoomImageView showLoading] 等方法来显示 loading。
- 由于 FWImagePreviewViewDelegate 继承自 FWZoomImageViewDelegate,所以若需要响应单击、双击、长按事件,请实现 FWZoomImageViewDelegate 里的对应方法。
- 若需要从指定的某一张图片开始查看,可使用 currentImageIndex 属性。
-
Undocumented
Declaration
Objective-C
@property(nonatomic, weak, nullable) id<FWImagePreviewViewDelegate> delegate
-
Undocumented
Declaration
Objective-C
@property(nonatomic, strong, readonly) UICollectionView *collectionView
-
Undocumented
Declaration
Objective-C
@property(nonatomic, strong, readonly) FWCollectionViewPagingLayout *collectionViewLayout
-
Undocumented
Declaration
Objective-C
@property(nonatomic, assign, readonly) NSInteger imageCount
-
获取当前正在查看的图片 index,也可强制将图片滚动到指定的 index
Declaration
Objective-C
@property (nonatomic) NSInteger currentImageIndex;
-
Undocumented
Declaration
Objective-C
- (void)setCurrentImageIndex:(NSInteger)currentImageIndex animated:(BOOL)animated;
-
图片数组,delegate不存在时调用,支持UIImage|PHLivePhoto|AVPlayerItem|NSURL|NSString等
Declaration
Objective-C
@property (nonatomic, copy, nullable) NSArray *imageURLs;
-
自定义图片信息数组,默认未使用,可用于自定义内容展示,默认nil
Declaration
Objective-C
@property (nonatomic, copy, nullable) NSArray *imageInfos;
-
占位图片句柄,仅imageURLs生效,默认nil
Declaration
Objective-C
@property (nonatomic, copy, nullable) UIImage *_Nullable (^) (NSInteger) placeholderImage;
-
是否自动播放video,默认NO
Declaration
Objective-C
@property (nonatomic) BOOL autoplayVideo;
-
自定义zoomImageView样式句柄,cellForItem方法自动调用,先于renderZoomImageView
Declaration
Objective-C
@property (nonatomic, copy, nullable) void (^) (FWZoomImageView *_Nonnull __strong, NSInteger) customZoomImageView;
-
自定义渲染zoomImageView句柄,cellForItem方法自动调用,优先级低于delegate
Declaration
Objective-C
@property (nonatomic, copy, nullable) void (^) (FWZoomImageView *_Nonnull __strong, NSInteger) renderZoomImageView;
-
自定义内容视图句柄,内容显示完成自动调用,优先级低于delegate
Declaration
Objective-C
@property (nonatomic, copy, nullable) void (^) (FWZoomImageView *_Nonnull __strong, __kindof UIView *_Nonnull __strong) customZoomContentView;
-
获取当前正在查看的zoomImageView,若当前 index 对应的图片不可见(不处于可视区域),则返回 nil
Declaration
Objective-C
@property (nonatomic, weak, readonly, nullable) FWZoomImageView *currentZoomImageView;
-
获取某个 FWZoomImageView 所对应的 index,若当前的 zoomImageView 不可见,会返回NSNotFound
Declaration
Objective-C
- (NSInteger)indexForZoomImageView:(nonnull FWZoomImageView *)zoomImageView;
-
获取某个 index 对应的 zoomImageView,若该 index 对应的图片当前不可见(不处于可视区域),则返回 nil
Declaration
Objective-C
- (nullable FWZoomImageView *)zoomImageViewAtIndex:(NSInteger)index;