         if nextIndex >= self.totalPages! {
             nextIndex = 0
         }
-        
+
         return (prevIndex, self.curPage!, nextIndex)
     }
-    
+
     private func refreshImages() {
         let page = self.getCurrentPage()
-        
+
         // 判断缓存
         if self.imageCacheDict[page.0] != nil {
             self.prevImageView.image = self.imageCacheDict[page.0]

        self.scrollView.isScrollEnabled = self.totalPages! > 1
        self.refreshImages()
    }
    
    public func enableAutoScroll(_ flag: Bool) {
        self.isAutoScroll = flag
    }
    
    public func setCurrentIndex(index: UInt) {
        if let count = self.totalPages {
            if index < count {
                self.curPage = index
                self.refreshImages()
            }
        }
        
    }
    
    // MARK: - Private Methods
    @objc private func imageViewClickAction() {
        let page = self.getCurrentPage()
        self.delegate?.clickCurrentImage(index: page.1)
    }
    
    @objc private func timerAction() {
        if self.isAutoScroll {
            self.scrollView.setContentOffset(CGPoint(x: self.bounds.width * 2, y: 0), animated: true)
        }
    }
    
    private func getCurrentPage() -> (UInt, UInt, UInt) {
        guard self.curPage != nil && self.totalPages != nil else {
            return (0, 0, 0)

            RunLoop.current.add(self.timer!, forMode: RunLoopMode.defaultRunLoopMode)
        }
    }

    func addMyViews() {
        self.scrollView.delegate = self
        self.scrollView.clipsToBounds = true
