 
 import UIKit
 
-private let identifi = "UICollectionViewCell"
+private let identifi = "PhotoCollectionCell"
 
 class BQPhotoBrowserView: UIView {
-
+    
     //MARK: - ***** Ivars *****
     fileprivate var datas: [UIImageView]!
     fileprivate var pageControl: UIPageControl!
     private var collectionView:UICollectionView!
     private var index: Int = 0
+    private var backView: UIView!
+    private var animationView: UIImageView!
     //MARK: - ***** Class Method *****
     
     class func show(datas:[UIImageView], current: Int = 0) {
         let browser = BQPhotoBrowserView(frame: UIScreen.main.bounds, datas: datas, current: current)
         UIApplication.shared.keyWindow?.addSubview(browser)
+        browser.startAnimation()
     }
     //MARK: - ***** initialize Method *****
     

        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() {
