
import Foundation
import UIKit

extension UIImageView{
    
    @IBInspectable
    var resizableImage: UIImage? {
        get {
            return self.image
        }
        set {
            if let image = newValue {
                self.image = image.resizableImage(withCapInsets: UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)).withRenderingMode(.alwaysTemplate)
            }
        }
    }
}

extension UIImageView{
    func getRatioHeight() -> CGFloat {
        guard let image = self.image else { return 0}
        let myImageWidth = image.size.width
        let myImageHeight = image.size.height
        let myViewWidth = self.frame.size.width
        
        let ratio = myViewWidth/myImageWidth
        let scaledHeight = myImageHeight * ratio
        
        return scaledHeight
    }
}
