 
 import UIKit
 
+fileprivate extension UIView {
+    func convertOriginToWindow() -> CGPoint {
+        return self.convert(CGPoint.zero, to: self.window)
+    }
+}
+
 open class DKPopoverViewController: UIViewController {
     
     @objc open class func popoverViewController(_ viewController: UIViewController, fromView: UIView, arrowColor: UIColor = UIColor.white) {

    override open func viewDidLoad() {
        super.viewDidLoad()
        
        self.popoverView = DKPopoverView(arrowColor: self.arrowColor)
        self.view.addSubview(self.popoverView)
    }

        }
        
        func commonInit() {
            self.arrowImageView.image = self.arrowImage()
            self.addSubview(self.arrowImageView)
        }
        
        override func layoutSubviews() {
            super.layoutSubviews()
            
            self.arrowImageView.frame = CGRect(x: (self.bounds.width - self.arrowWidth) / 2 + self.arrowOffset.x,
                                               y: self.arrowOffset.y,
                                               width: self.arrowWidth, height: self.arrowHeight)
            self.contentView.frame = CGRect(x: 0, y: self.arrowHeight, width: self.bounds.width,
                                            height: self.bounds.height - self.arrowHeight)
        }
        
        func arrowImage() -> UIImage {
