     /// Config the imageView's `image`
     func config(image: UIImage?) {
         imageView.image = image
-        guard let image = image else { return }
-        let newHeight = image.size.height * bounds.width / image.size.width
-        let newWidth = bounds.width
-        imageView.frame = CGRect(x: 0, y: 0, width: newWidth, height: newHeight)
-        if newHeight < bounds.height {
-            imageView.center = center
-        } else {
-            contentSize = CGSize(width: newWidth, height: newHeight)
-        }
+        refreshFrame()
     }
 }
 

        }
        
        func _configViews() {
            
            delegate = self
            minimumZoomScale = 0.5
            maximumZoomScale = 2.5

            tap.require(toFail: doubleTap)
        }
        
        func _addObserver() {
            NotificationCenter.default.addObserver(self, selector: #selector(orientationDidChanged(notify:)), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
        }
        
        _addViews()
        _configViews()
        _addObserver()
        layoutViews()
    }
    
    func layoutViews() {
    }
    
    func refreshFrame() {
        guard let image = imageView.image else { return }
        let newHeight = bounds.height
        let newWidth = newHeight * image.size.width / image.size.height
        let size = CGSize(width: newWidth, height: newHeight)
        setZoomScale(1, animated: false)
        contentSize = size
        imageView.frame = CGRect(x: 0, y: 0, width: newWidth, height: newHeight)
        refreshImageViewCenter()
    }
    
    func refreshImageViewCenter() {
        let offsetX = bounds.width > contentSize.width ? (bounds.width - contentSize.width) * 0.5 : 0
        let offsetY = bounds.height > contentSize.height ? (bounds.height - contentSize.height) * 0.5 : 0
        imageView.center = CGPoint(x: contentSize.width * 0.5 + offsetX, y: contentSize.height * 0.5 + offsetY)
