展开 UIView 时如何向下移动文本字段 (Swift)

How can i move textfield down When UIView is expanded (Swift)

这是我在 viewDidLoad() 中的代码

override func viewDidLoad() {
    super.viewDidLoad()

    expandView.frame.size.height = 36
}

当我按下展开按钮时

@IBAction func expandPressed(sender: AnyObject) {

    if(expandView.frame.size.height == 36)
    {
        expandView.frame.size.height = 200;
    }
    else
    {
        expandView.frame.size.height = 36;
    }
}

这是我得到的输出,它覆盖了我的下一个文本字段。如果展开视图,如何使 Address textField 向下移动?

您可以在函数中设置文本框:

if(expandView.frame.size.height == 36){
    expandView.frame.size.height = 200;
    textfield.frame.origin.y = textfield.frame.origin.y + 164
}
else{
    expandView.frame.size.height = 36;
    textfield.frame.origin.y = textfield.frame.origin.y - 164
}

希望对你有帮助! 这是结果: