谁能告诉我为什么我的计算按钮没有显示?

时间:2020-05-16 05:03:43

标签: swift

import UIKit

class MainVC: UIViewController {

    @IBOutlet weak var wageTxt: CurrencyTextField!
    @IBOutlet weak var priceTxt: CurrencyTextField!

    override func viewDidLoad() {
        super.viewDidLoad()

        let calcBtn = UIButton(frame:CGRect(x:0, y:0,width:view.frame.size.width, height:60))
        calcBtn.backgroundColor = #colorLiteral(red: 0.9372549057, green: 0.3490196168, blue: 0.1921568662, alpha: 1)
        calcBtn.setTitle("Calculate", for: .normal)
        calcBtn.setTitleColor(#colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0), for: .normal)
        calcBtn.addTarget(self, action:#selector(MainVC.calculate), for: .touchUpInside)

        wageTxt.inputAccessoryView = calcBtn
        priceTxt.inputAccessoryView = calcBtn
    }

    @objc func calculate(){
        print("we got here")
    }

}

我的键盘正在显示,但是“计算”按钮没有弹出。我尝试了所有可能的方式。

0 个答案:

没有答案