如何使用TextField并导入其他TextField?

我想在按数字按钮时在TextFeild中导入数字,并在按“按钮”时在Current TextFelid旁边导入新的TextFeild。但是这段代码是用来移动CurrentTextFelid的。按下数字按钮时,我不想移动TextField。如果我导入String重置代码(String =“”),则当我按数字按钮时,它会显示当前数字。如果我不编写重置代码,则可以将其导入TextField中。 我该怎么办?

func getWidth(text: String, tf : UITextField) -> CGFloat
    {
        tf.text = text
        tf.sizeToFit()
        return tf.frame.size.width
    }
    @IBAction func digit(_ sender: UIButton) {
        let digit = sender.currentTitle //현재 입력된 버튼 숫자를 들고옴
        string += digit!
        textField[ArrayNum-1].insertText(string) //백그라운드에 숫자를 들고옴
        textField[ArrayNum-1].frame = CGRect(x: textField[ArrayNum-1].frame.origin.x, y: txtField.frame.origin.y, width: getWidth(text: string, tf: textField[ArrayNum-1]), height: textField[ArrayNum-1].frame.height)
    }

    func Textfieldfunc() {
        textField.append(txtField)
        String = ""
        textField[ArrayNum-1].text! = ""
        if ArrayNum==1 {
            textField[ArrayNum-1].frame = CGRect(x: 10, y: 100, width: 30, height: 38)
            textField[ArrayNum-1].borderStyle = .roundedRect
            self.view.addSubview(textField[ArrayNum-1])
        }
        else {
            textField[ArrayNum-1].frame = CGRect(x: 10+getWidth(text: string, tf: textField[ArrayNum-2]), y: 100, width: 30, height: 38)
            textField[ArrayNum-1].borderStyle = .roundedRect
            self.view.addSubview(textField[ArrayNum-1])
        }

    }
}

此代码是第一张图片。 第二张图片是不写String重置代码的图片。

enter image description here enter image description here