     }
 }
 
-extension BQPhotoBrowserView: UICollectionViewDelegate, UICollectionViewDataSource {
+extension BQPhotoBrowserView: UICollectionViewDelegate, UICollectionViewDataSource, PhotoCellDelegate {
     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
         return self.datas.count
     }
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
-        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifi, for: indexPath)
-        cell.backgroundColor = UIColor.randomColor
+        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifi, for: indexPath) as! PhotoCollectionCell
+        cell.delegate = self
+        cell.row = indexPath.row
+        cell.setImage(img: self.datas[indexPath.row].image)
         return cell
+    }
+    func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
+        let photoCell = cell as! PhotoCollectionCell
+        photoCell.photoView.zoomNormal()
+    }
+    func photoTapAction(row: Int) {
+        self.removeSelf(row: row)
     }
 }
 

        self.pageControl.currentPage = Int((scrollView.contentOffset.x + scrollView.width * 0.5) / scrollView.width)
    }
}

        
    }
    private func initUI() {
        self.backView = UIView(frame: self.bounds)
        self.backView.backgroundColor = UIColor.black
        self.addSubview(self.backView)
        self.createCollection()
        self.createPageContrl()
        self.animationView = UIImageView(frame: CGRect.zero)
        self.addSubview(self.animationView)
        self.collectionView.scrollToItem(at: IndexPath(item: self.index, section: 0), at: .centeredHorizontally, animated: false)
    }
    private func startAnimation() {
        let imgView = self.datas[self.index]
        self.animationView.frame = imgView.superview!.convert(imgView.frame, to: UIApplication.shared.keyWindow?.rootViewController?.view)
        self.backView.alpha = 0
        self.collectionView.alpha = 0
        self.pageControl.alpha = 0
        
        UIView.animate(withDuration: 0.25, animations: {
            self.configImgFrame(imgView: imgView)
            self.backView.alpha = 1
        }) { (flag) in
            self.animationView.alpha = 0
            self.collectionView.alpha = 1
            self.pageControl.alpha = 1
        }
    }
    fileprivate func removeSelf(row:Int)  {
        print("第\(row)个被点击")
        self.index = row
        let imgView = self.datas[self.index]
        let toFrame = imgView.superview!.convert(imgView.frame, to: UIApplication.shared.keyWindow?.rootViewController?.view)
        self.configImgFrame(imgView: imgView)
        self.animationView.alpha = 1
        self.collectionView.alpha = 0
        self.pageControl.alpha = 0
        UIView.animate(withDuration: 0.25, animations: {
            self.backView.alpha = 0
            self.animationView.frame = toFrame
        }) { (finish) in
            self.removeFromSuperview()
        }
    }
    func configImgFrame(imgView:UIImageView) {
        let imgSize = imgView.image!.size
        let height = imgSize.height * (self.width - 16) / imgSize.width
        let frame = CGRect(x: 8, y: (self.height - height) * 0.5, width: (self.width - 16), height: height)
        self.animationView.image = self.datas[self.index].image
        self.animationView.frame = frame
    }
    //MARK: - ***** LoadData Method *****
    
    //MARK: - ***** respond event Method *****
    
    //MARK: - ***** create Method *****
    func createCollection() {
