Set Left and right button for the UITextField in swift

class DesignModel: NSObject {

    class func setLeftButton(_ textField: UITextField, image: UIImage) {
        let imageView = UIImageView(frame: CGRect(x: CGFloat(0), y: CGFloat(0), width: CGFloat(50), height: CGFloat(10
        )))
        imageView.image = image
        imageView.contentMode = .center
        textField.leftViewMode = .always
        textField.leftView = imageView
    }
    
    class func setRightButton(_ textField: UITextField, image: UIImage) {
        let imageView = UIImageView(frame: CGRect(x: CGFloat(0), y: CGFloat(0), width: CGFloat(40), height: CGFloat(20)))
        imageView.image = image
        imageView.contentMode = .center
        textField.rightViewMode = .always
        textField.rightView = imageView
    }
}