【问题标题】:How can i move textfield down When UIView is expanded (Swift)UIView 展开时如何向下移动文本字段(Swift)
【发布时间】:2016-10-19 12:56:23
【问题描述】:

这是我在 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 向下移动?

【问题讨论】:

    标签: swift uiview expandablelistview textfield expandable


    【解决方案1】:

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

    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
    }
    

    希望能帮到你! 结果如下:

    【讨论】:

    • 你也可以用它来制作动画...UIView.animate(withDuration: 1.0) { // your code here }
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-10-26
    • 2015-05-01
    • 1970-01-01
    • 2015-08-20
    • 1970-01-01
    • 2021-04-01
    • 2020-11-06
    相关资源
    最近更新 更多