BMGallery 0.1.0

BMGallery 0.1.0

Lee Zhe Yu 维护。



BMGallery 0.1.0

  • LEE ZHE YU

BMGallery

CI Status Version License Platform

关于

BMGallery 提供了一种简单的方式来使用,创建类似于 TikTok 的过渡动画,并将其应用于将 UICollectionCell 推入一个 detail UIViewController 的场景。

DEMO

示例

要运行示例项目,首先克隆仓库,然后在 Example 目录中运行 pod install

用法

创建一个扩展BMGallery的UIView

实现BMGalleryDataSource和BMGalleryDelegate并同时将其分配给画廊

设置画廊的布局(有两种选项:aspect和fixHeight)

bmoGallery.delegate = self
bmoGallery.dataSource = self
bmoGallery.layoutType = .aspect(ratio: 30 / 23, itemCountOfLine: 3, margin: 8.0)

在bmGalleryDataSourceNumberOfItems中返回单元格数量

func bmGalleryDataSourceNumberOfItems(in galleryView: BMGallery) -> Int {
    return datas.count
}

构建单元格视图内容

func bmGalleryDataSourceContentViewForItem(at: Int, contentView: UIView) {
}

最后,在bmGalleryDelegateItemSelected或其他动作中告诉galleryView推送下一页

galleryView.transition.push(vc, to: navigationController, fromItem: at)

注意:详情页面必须实现 BMGalleryTransitioningDestination,必须使用 sourceBMGallery 进行弹出

class DetailViewController: UIViewController, BMGalleryTransitioningDestination {
    @IBAction func closeAction(_ sender: Any) {
        self.sourceBMGallery?.transition.pop(from: navigationController)
    }
}

需求

iOS 9.0 + Swift 5

安装

BMGallery 可通过 CocoaPods 获得。要安装它,只需在 Podfile 中添加以下行

pod 'BMGallery'

作者

李哲宇,[email protected]

许可证

BMGallery 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。