图片管理,图片浏览器,九宫格布局

# LXPhotosManagerModule

#### 项目介绍

 **

### 最完美、最轻量级的图片管理!

** 

#### 安装说明

方式1 : cocoapods安装库 

        ** pod 'LXPhotosManager'

        pod install** 

方式2:   **直接下载压缩包 解压**    **LXPhotosManager **   

#### 使用说明

 **下载后压缩包 解压   请先 pod install  在运行项目** 

###  模型数据 必须遵守协议  FileInfoProtocol

  

```

class FileModel: FileInfoProtocol {

    var image: UIImage = UIImage()

    var height: CGFloat = 0.0

    var width: CGFloat = 0.0

    var imgUrl: String = ""

 }

```

####九宫格展示(微信朋友圈图片方式)

```

  let photoVeiw = NineGridPhotosView(frame: CGRect(x: 0, y: 100, width: UIScreen.main.bounds.width, height: 600))

  photoVeiw.delegate = self

  photoVeiw.loadBlock = { model, imgView in

     imgView.kf.setImage(with: URL(string: model.imgUrl)!)

  }

  photoVeiw.datasource = [model,model1,model2,model3,model4]

  view.addSubview(photoVeiw)

```

####九宫格展示 点击调用图片浏览器 (图片浏览)

```

  let pView = PhotosBrowserView()

  pView.imgViews = [imgView,imgView1,imgView2]

  pView.loadBlock = { model, imgView in

    imgView.kf.setImage(with: URL(string: model.imgUrl)!)

  }

  pView.photos = [model,model1,model2]

  let index =  [imgView,imgView1,imgView2].firstIndex(of: gesture.view) ?? 0

  pView.startAnimation(with: index, cellType: false)

```

####UICollectionView 点击调用图片浏览器 (图片浏览)

```

  //图片浏览器

  let pView = PhotosBrowserView()

  pView.delegate = self

  pView.loadBlock = { model, imgView in

    imgView.kf.setImage(with: URL(string: model.imgUrl)!)

  }

  pView.photos = models

  pView.startAnimation(with: indexPath.item, cellType: true)

  

  //必须实现代理方法

  extension ViewController: PhotosBrowserViewDelagete {

      func photosBrowserView(cellIndex: Int, photos: [FileInfoProtocol]) -> UIView {

          return collectionView.cellForItem(at: IndexPath(item: cellIndex, section: 0)) ?? UIView()

      }

  }

  

```

 demo : https://github.com/LIXIANGXLee/LXPhotosManagerModule.git

猜你喜欢

转载自www.cnblogs.com/lnxlee/p/12716831.html