如何将数据从UIViewsController传递到UIView,Swift

我正在尝试将数据从UIViewcoontroller传递到UIView。 我希望将金额值传递给UIView,我需要它通过UIView中的按钮发送请求。

//this is my UIViewController

final class PayParkingViewController: BaseViewController {
    @IBOutlet weak var amount: UITextField!
//for example I need this myAmount value to be passed in my UIView
myAmount = amount.text
}
//This is my UIView
final class PaymentChoice: UIView {

    @IBOutlet weak var mastercard: UIButton!
    @IBOutlet var contentView: UIView!


      override init(frame: CGRect) {
         super.init(frame: frame)

         commonInit()
     }

     required init?(coder aDecoder: NSCoder) {
         super.init(coder: aDecoder)
         commonInit()
     }

     private func commonInit() {
             Bundle.main.loadNibNamed(className, owner: self, options: nil)
         guard let content = contentView else { return }
         addSubview(content)
         content.frame = bounds
         content.autoresizingMask = [.flexibleWidth, .flexibleHeight]
     }
    @IBAction func mastercardIsSelected(_ sender: Any) {

// here I need myAmount value from my UIViewController

    }
评论