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

时间:2016-10-19 12:56:23

标签: swift uiview expandablelistview textfield expandable

这是我在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;
    }
}

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

enter image description here

1 个答案:

答案 0 :(得分:3)

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

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
}
希望能帮助你! 这是结果:

enter image description here