             
             UIView.animate(withDuration: 0.25, animations: { () -> Void in
                 self.shadowImageView.frame = CGRect(x: sender.frame.origin.x, y: 0,
-                    width: sender.frame.size.width, height: self.shadowImage.size.height)
-                }, completion: { (finished) -> Void in
-                    if finished == true {
-                        //  设置新页面出现
-                        if self.isRootScroll == false {
-                            self.rootScrollView.setContentOffset(CGPoint(x: CGFloat(sender.tag - 100) * self.bounds.width, y: 0), animated: true)
-                        }
-                        self.isRootScroll = false
-                        
-                        if let delegate = self.delegate {
-                            if (delegate as! UIViewController).responds(to: #selector(RGSwitchViewDelegate.switchView(_:didSelectTab:))) {}
-                            delegate.switchView?(self, didSelectTab: self.userSelectedChannelID - 100)
-                        } else {
-                            print("delegate in RGSwitchView is nil", terminator: "")
-                        }
-                        
+                                                    width: sender.frame.size.width, height: self.shadowImage.size.height)
+            }, completion: { (finished) -> Void in
+                if finished == true {
+                    //  设置新页面出现
+                    if self.isRootScroll == false {
+                        self.rootScrollView.setContentOffset(CGPoint(x: CGFloat(sender.tag - 100) * self.bounds.width, y: 0), animated: true)
                     }
+                    self.isRootScroll = false
+
+                    if let delegate = self.delegate {
+                        if (delegate as! UIViewController).responds(to: #selector(RGSwitchViewDelegate.switchView(_:didSelectTab:))) {}
+                        delegate.switchView?(self, didSelectTab: self.userSelectedChannelID - 100)
+                    } else {
+                        print("delegate in RGSwitchView is nil", terminator: "")
+                    }
+
+                }
             })
         } else {    //  重复点击选中按钮
             

            for i in 0 ..< viewArray.count {
                let listVC = viewArray[i]
                listVC.view.frame = CGRect(x: 0 + rootScrollView.bounds.width * CGFloat(i), y: 0,
                    width: rootScrollView.bounds.width, height: rootScrollView.bounds.height)
            }
            
            //  滚动到选中的视图

            topScrollView.setContentOffset(CGPoint(x: sender.frame.origin.x - kWidthOfButtonMargin, y: 0), animated: true)
        }
    }

    @objc fileprivate func scrollHandlePan(_ panParam: UIPanGestureRecognizer) {
        if rootScrollView.contentOffset.x <= 0 {
            if delegate != nil && (delegate as! UIViewController).responds(to: #selector(RGSwitchViewDelegate.switchView(_:panLeftEdge:))) {
