测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可协议 | MIT |
发布时间上次发布 | 2017年4月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 SunnyLinSD 维护。
一款轻量级的图片浏览器,采用全 Swift
编写,依赖于 Kingfisher
图片下载库,支持本地以及网络图片浏览。
SDPhotoBrowserViewController
浏览器let photoBrowserViewController = SDPhotoBrowserViewController()
photoBrowserViewController.photoUrlArray = photoUrl
// self.navigationController?.pushViewController(photoBrowserViewController, animated: true)
self.present(photoBrowserViewController, animated: true, completion: nil)
SDPhotoBrowserViewController
提供的快速构造方法,将图片数组和 startIndex
传递给 SDPhotoBrowserViewController
的实例对象。let photoBrowserViewController = SDPhotoBrowserViewController(WithPhotoUrlArray: photoUrl, startIndex: 0, delegate: self)
// self.navigationController?.pushViewController(photoBrowserViewController, animated: true)
self.present(photoBrowserViewController, animated: true, completion: nil)
SDPhotoBrowserViewController
的 func config(named name: String, of position: SDButtonPosition, callBack: (() -> Void)?)
方法,如下所示:photoBrowserViewController.configNavBarButton(named: "nav_close_on", of: .rightOne, callBack: nil)
SDPhotoBrowserViewControllerDelegate
的代理方法,可以自定义 toolView
,默认情况下 toolView
显示在浏览器的底部位置。func toolViewHeight(for photoBrowser: SDPhotoBrowserViewController) -> CGFloat {
return 120
}
func customToolView(for photoBrowser: SDPhotoBrowserViewController) -> UIView {
let toolView = UIView()
toolView.backgroundColor = UIColor(white: 0.0, alpha: 0.8)
titleLabel = UILabel()
titleLabel.textColor = UIColor.white
titleLabel.translatesAutoresizingMaskIntoConstraints = false
toolView.addSubview(titleLabel)
toolView.addConstraint(NSLayoutConstraint(item: titleLabel, attribute: .centerY, relatedBy: .equal, toItem: toolView, attribute: .centerY, multiplier: 1.0, constant: 0))
toolView.addConstraint(NSLayoutConstraint(item: titleLabel, attribute: .left, relatedBy: .equal, toItem: toolView, attribute: .left, multiplier: 1.0, constant: 15))
toolView.addConstraint(NSLayoutConstraint(item: titleLabel, attribute: .right, relatedBy: .equal, toItem: toolView, attribute: .right, multiplier: 1.0, constant: -15))
return toolView
}
toolView
上控件的显示,只需实现以下代理方法即可。func photoBrowser(_ photoBrowser: SDPhotoBrowserViewController, didChangedToPageAtIndex index: Int) {
titleLabel.text = photoTitleArray[index]
}