PhotoViewerController
示例
为了使用这个库,您首先需要安装 Pod。然后,将 PhotoViewerController 导入到您的项目中
import PhotoViewerController
然后初始化一个 PhotoViewerController 对象,设置其代理,初始化项索引。为了实现期望的行为,设置其 modalPresentationStyle 为 .overFullScreen。
示例
let photoViewer = PhotoViewerController()
photoViewer?.delegate = self
photoViewer?.initialItemIndex = 3
photoViewer?.modalPresentationStyle = .overFullScreen
您还应当实现它的代理方法
示例
extension ViewController: PhotoViewerControllerDelegate{
func numberOfItems(in photoViewer: PhotoViewerController) -> Int {
// provide the number of items to display.
}
func numberOfActions(in photoViewer: PhotoViewerController, forItemAt index: Int) -> Int {
// provide the number of actions for an item diplayed at index in photoViewer.
}
func photoViewer(_ photoViewer: PhotoViewerController, imageView: UIImageView, at index: Int) {
// customize the imageView provided for an item to display at index in photoViewer.
}
func photoViewer(_ photoViewer: PhotoViewerController, topBarLeftItemsAt index: Int) -> [UIBarButtonItem] {
// provide an array of left top bar items for the the item to display at index.
}
func photoViewer(_ photoViewer: PhotoViewerController, topBarRightItemsAt index: Int) -> [UIBarButtonItem] {
// provide an array of right top bar items for the the item to display at index.
}
func photoViewer(_ photoViewer: PhotoViewerController, actionBarButton button: UIButton, at position: Int, forItemAt index: Int) {
// customize the provided action button at position for an item to display at index in photoViewer.
}
func photoViewer(_ photoViewer: PhotoViewerController, titleForItemAt index: Int) -> String {
// provide a title for an item to display at index in photoViewer.
}
func photoViewer(_ photoViewer: PhotoViewerController, captionForItemAt index: Int) -> String {
// provide a caption text for an item to display at index in photoViewer.
}
}
完成后,您就可以展示 PhotoViewer 了
self.present(photoViewer!, animated: true, completion: nil)
要求
安装
PhotoViewerController 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'PhotoViewerController'
作者
Botirjon Nasridinov,[email protected]
许可
PhotoViewerController 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。