Code Monkey home page Code Monkey logo

llphotobrowser's Introduction

License Platform

Download

由于当前仓库存在gif图,下载包较大,请点击下面的【下载源代码】极速下载哦,源代码下载方码云

👉 下载源代码

Support

  • 支持识别二维码
  • 支持网络图,本地图,UIImage同时使用
  • 支持网络图片加载
  • 支持图片放大缩小
  • 支持双击放大指定位置
  • 支持滑动查看及横屏切换图片
  • 支持当前页/总页数显示
  • 支持单击关闭
  • 支持长按弹出功能窗口
  • 支持自定义功能增加
  • 支持图片数据的延时加载
  • 支持没有数据,占位图占位
  • 支持非物理横屏看图

Demo

二维码检测

let browser = LLPhotoBrowserViewController.init(photoArray: data, currentIndex: indexPath.row, sheetTitileArray: ["分享给朋友","保存到相册"], isOpenQRCodeCheck: true) { (index, imageView, qrcodeString) in
  print("ActionSheet点击-->下标=\(index); ImageView:\(imageView); qrcodeString:\(String(describing: qrcodeString))")

  if let qrcode = qrcodeString {
    UIAlertView.init(title: "二维码地址", message: qrcode, delegate: self, cancelButtonTitle: "取消").show()
}
}
browser.presentBrowserViewController()

图片正常浏览

检测设备横屏

let browser = LLPhotoBrowserViewController.init(photoArray: data currentIndex: indexPath.row)
// 模态弹出
browser.presentBrowserViewController()

Action Sheet

检测设备横屏 Action Sheet

let browser = LLPhotoBrowserViewController.init(photoArray: data, currentIndex: indexPath.row, sheetTitileArray: ["分享给朋友","保存到相册"]) { (index, imageView, qrcodeString) in
  print(index)
}
// 模态弹出
browser.presentBrowserViewController()

Update

版本信息 更新描述
1.1.0  * 优化关于图片不在可视区域的图片消失
1.0.9   * Swift 4
1.0.8   * Swift 3
1.0.7   * 修复单击退出时的快速滚动崩溃错误
1.0.6   * 增加ActionSheet的自定义样式
1.0.5   * 修复不使用长按后的闪退问题
1.0.4   * Add Open
1.0.3   * 修复Pod后提示性图片不显示
1.0.2   * 增加图片中二维码检测,目前仅支持单个链接二维码
1.0.1   * 增加支持网络图,本地图,UIImage同时使用
* HTTPString, UIImage, 文件名称String
1.0.0   * 项目初始化

CocoaPods

  • Add pod 'LLPhotoBrowser' to your Podfile.
    • Swift 3 pod 'LLPhotoBrowser', '1.0.8'
    • Swift 4 pod 'LLPhotoBrowser' 或者 pod 'LLPhotoBrowser', '~> 1.1.0'
  • Run pod install or pod update.
  • Add import LLPhotoBrowser

Usage

对象封装(见Demo里LLCollectionViewController.swift)

var data: [LLBrowserModel] = []
for index in 0..<bigUrlArray1_0_1.count {
  let cell: LLCollectionViewCell? = collectionView.cellForItem(at: IndexPath.init(row: index, section: 0)) as? LLCollectionViewCell
  let model = LLBrowserModel.init()
  model.data = bigUrlArray1_0_1[index]
  if let c = cell {
    model.sourceImageView = c.ll_imageView
  }
  data.append(model)
}

简单的图片浏览

let browser = LLPhotoBrowserViewController.init(photoArray: <#数组([LLBrowserModel])#>, currentIndex: <#当前索引(row)#>)
// 模态弹出
browser.presentBrowserViewController()

支持长按弹出AcitonSheet工具

let browser = LLPhotoBrowserViewController.init(photoArray: <#数组([LLBrowserModel])#>, currentIndex: <#当前索引(row)#>, sheetTitileArray: <#工具菜单标题([String])#>) { (<#点击工具菜单下标#>, <#当前显示的imageView#>, <#二维码结果返回#>) in
  // 点击事件处理
  print("ActionSheet点击-->下标=\(index)")
}
// 模态弹出
browser.presentBrowserViewController()

支持类型,你可以这么玩1.0.1

/// 1.0.1版本 数据源
let bigUrlArray1_0_1: [Any?] = [ "http://car0.autoimg.cn/upload/spec/5900/1024x0_1_q87_2011071303265437981.jpg",
                                 // 文件名称
                                 "timg",
                                 "timg-1",
                                 // URL
                                 "http://img1a.xgo-img.com.cn/pics/2153/b2152556.jpg",
                                 "http://4493bz.1985t.com/uploads/allimg/140826/3-140R6142K1.jpg",
                                 // UIImage
                                 UIImage.init(named: "timg-5"),
                                 UIImage.init(named: "timg-7"),
                                 // URL
                                 "http://4493bz.1985t.com/uploads/allimg/140825/3-140R5115546.jpg"]

是否开启二维码检测1.0.2

let browser = LLPhotoBrowserViewController.init(photoArray: data, currentIndex: indexPath.row, sheetTitileArray: ["分享给朋友","保存到相册"], isOpenQRCodeCheck: true) { (index, imageView, qrcodeString) in
  print("ActionSheet点击-->下标=\(index); ImageView:\(imageView); qrcodeString:\(String(describing: qrcodeString))")

  if let qrcode = qrcodeString {
    UIAlertView.init(title: "二维码地址", message: qrcode, delegate: self, cancelButtonTitle: "取消").show()
}
}
browser.presentBrowserViewController()

开放ActionSheet自定义1.0.6

/// Cell Height default 44.0
open var actionSheetCellHeight: CGFloat? = 44.0

/// Cell Background Color default white
open var actionSheetCellBackgroundColor: UIColor? = UIColor.white

/// Title Font default UIFont.systemFont(ofSize: 15.0)
open var actionSheetTitleFont: UIFont? = UIFont.systemFont(ofSize: 15.0)

/// Title Color default black
open var actionSheetTitleTextColor: UIColor? = UIColor.black

/// Cancel Color default black
open var actionSheetCancelTextColor: UIColor? = UIColor.black

/// Cancel Title default 取消
open var actionSheetCancelTitle: String? = "取消"

/// Line Color default 212.0 212.0 212.0
open var actionSheetLineColor: UIColor? = UIColor.init(red: 212.0/255.0, green: 212.0/255.0, blue: 212.0/255.0, alpha: 1.0)

Example

示例代码见LLCollectionViewController.swift

Issues

如果使用过程中,有什么问题欢迎issues。

Author

LvJianfeng, [email protected]

llphotobrowser's People

Contributors

lvjianfeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

llphotobrowser's Issues

显示加密图片

显示加密图片时,如果在设置model的时候做图片解密操作太耗时间,所有选择在设置图片的时候做图片解密操作,故而需要重写func loadBrowserImagerWithModel(item: LLBrowserModel, cell: LLBrowserCollectionViewCell, imageFrame: CGRect)方法,所以需要公开该方法。

动画效果

点击图片回到原来位子,会出现白色view,不知道是什么,这样体验不好

快速浏览图片右问题

进入大图浏览模式时,你点击一下图片然后快速左右移动一下图片就会crash

断点定位崩溃

LLBrowserViewController.swift line: 367

解决: 要先判断indexPath
if let indexPath = collectView?.indexPath(for: cell) {
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
...
把单机退出浏览模式的相关代码放里面
}

建议

在model里面除了有http,应该也有https的判断,希望有缩略图和大图的展示,而不是只有默认图

可以修改弹出效果吗?

可以修改弹出那个效果吗? 目前好像是从左上角往右下角弹出, 有时候好像是旋转进来的?
可以改成像微信一样放大出来不?

还有另外一个问题是, 当打开图片后, 一个手指稍微滑一下就突然放大了好多. 不知这个有无开关, 单个手指不放大. 双指才放大

建议压缩下需要下载的部分

100多M啊大哥...,github虽然没锁网,但是有时候在git上下载速度还是很慢的,100多兆真的很难下载的,建议只保留核心代码,加点示例最好也要保持下载包不超过20M,10M以内最好,100多兆真的不利于推广,不希望你写的辛辛苦苦被这种下载问题挡住了

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.