KNPhotoBrowser 2.6.7

KNPhotoBrowser 2.6.7

LuKane 维护。



  • LuKane

image

CocoaPods CocoaPods Support 

KNPhotoBrowser

中文 | 英文

中国最受欢迎的类似微信(TX)和微博(Sina)的照片或视频浏览器

如果需要添加任何功能,请通过电子邮件联系我。欢迎使用Star

imageimageimageimageimage

更新内容

描述
基于UIViewController
适配屏幕旋转,iPad分屏
适配iPhone5至iPhone14Pro_Max
定位并获取图片和GIF图片
定位并获取视频
PageControl可添加目标以改变值 [API]
PanGesture用于取消或放弃(普通图片、长图片、视频) [API]
预取图片,最多8张 [API]
视频播放器自动播放 [API]
视频播放器支持倍速播放 [API]
视频播放器支持在线播放(无缓存,无下载) [API]
视频播放器支持下载后播放(下次搜索) [API]
在PhotoBrowser上显示自定义视图 [API]
在PhotoBrowser上显示自定义视图,并设置动画跟随PhotoBrowser [API]
在PhotoBrowser显示前,所有图像控制都可以自定义 [API]
所有操作通过代理进行 [Delegate]
推送ViewController(2022-12) [API]
重新加载collection数据源(2022-12) [API]

1.在使用前需要知道

  • 1.依赖库>=SDWebImage(5.0),如果需要定位GIF图片,则依赖>=SDWebImage(5.8.3)
  • 2.图片和视频播放已准备好使用
  • 3.图片或视频下载已准备好使用
  • 4.自定义控件如您所愿
  • 5.自动管理下载的图片和视频已完成

2. 如何使用

(1).初始化基本参数

// 1.make every control as an object, put it into an array
KNPhotoItems *items = [[KNPhotoItems alloc] init];
items.url = @"http://xxxxxxxx/xxx.png";
items.sourceView = imageView;
// if current url is video type
// items.isVideo = true;
// if current image is locate gif
// itemM.isLocateGif = true;
[self.itemsArr addObject:items];

(2).初始化PhotoBrowser

KNPhotoBrowser *photoBrowser = [[KNPhotoBrowser alloc] init];
photoBrowser.itemsArr = [self.itemsArr copy];
photoBrowser.currentIndex = tap.view.tag;

/// photoBrowser will present
[photoBrowser present];

/// photoBrowser will dismiss
/// [photoBrowser dismiss];

(3).代理函数描述

PhotoBrowser 将关闭
/// photoBrowser will dismiss with currentIndex
- (void)photoBrowser:(KNPhotoBrowser *)photoBrowser willDismissWithIndex:(NSInteger)index;
PhotoBrowser 右侧按钮点击事件
/// photoBrowser right top button did click with currentIndex (you can custom you right button, but if you custom your right button, that you need implementate your target action)
- (void)photoBrowser:(KNPhotoBrowser *)photoBrowser rightBtnOperationActionWithIndex:(NSInteger)index;

.....

(4). 浏览器组件:KNPhotoItems

项目的默认参数
/// if it is network image,  set `url` , do not set `sourceImage`
@property (nonatomic,copy  ) NSString *url;

/// if it is locate image, set `sourceImage`, do not set `url`
@property (nonatomic,strong) UIImage *sourceImage;

/// sourceView is current control to show image or video.
/// 1. if the sourceView is kind of `UIImageView` or `UIButton` , just only only only set the `sourceView`.
/// 2. if the sourceView is the custom view , set the `sourceView`, but do not forget set `sourceLinkArr` && `sourceLinkProperyName`.
@property (nonatomic,strong) UIView *sourceView;
自定义数据源视图(非常棒)
@property (nonatomic,strong) NSArray<NSString *> *sourceLinkArr;

/**
 eg:
    if the lastObject is kind of  UIImageView ,  the `sourceLinkProperyName` is `image`
    if the lastObject is kind of  UIButton ,  the `sourceLinkProperyName` is `currentBackgroundImage` or `currentImage`
 */

/// the property'name of the  sourceLinkArr lastObject
@property (nonatomic,copy  ) NSString *sourceLinkProperyName;

3. 安装方法

pod 'KNPhotoBrowser'

// terminal : cd ~(current path)
pod install or pod update

顺便一说

  • 如果你有任何想法,请与我联系!谢谢