             if refreshState == .pulling {
                 refreshState = .refreshing
             }
-            
-            
-            
+           
         }
-        
-        
-        
-        
-        
+       
     }
     
     

        //判断类型
        if newSuperview is UIScrollView {
            //记录父控件
            self.scrollview = newSuperview as! UIScrollView
            //添加观察者
            self.scrollview?.addObserver(self, forKeyPath: "contentOffset", options: [.new], context: nil)
        }

class WYRefreshControl: UIControl {

    //刷新的状态
    var refreshState : WYRefreshType = .normal {
        
        didSet {
            switch refreshState {
            case .pulling:
                //调转箭头
                UIView.animate(withDuration: 0.25, animations: { 
                    self.arrowIcon.transform = CGAffineTransform.init(rotationAngle: CGFloat(M_PI))
                })
                self.messageLabel.text = "松开起飞"
            case .normal:
                //关闭菊花转
                indicatorView.stopAnimating()
                //箭头显示出来
                arrowIcon.isHidden = false
                UIView.animate(withDuration: 0.25, animations: { 
                    self.arrowIcon.transform = CGAffineTransform.identity
                })
                self.messageLabel.text = "等待起飞"
            case .refreshing:
                arrowIcon.isHidden = true
                indicatorView.isHidden = false
                indicatorView.startAnimating()
                self.messageLabel.text = "正在起飞"
            
                // 如果让其在转的时候停止在界面的顶端
                // 为tableView顶部增加多余的滑动距离
                var inset = self.scrollview!.contentInset
                inset.top += HMRefreshControlH
                self.scrollview?.contentInset = inset
                
            }
        }
        
    }
    //记录父控件(也就是记录tableview)
    var scrollview : UIScrollView?
    
