swiftuiviewexpandablelistviewtextfieldexpandable

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


This is my code in viewDidLoad()

override func viewDidLoad() {
    super.viewDidLoad()

    expandView.frame.size.height = 36
}

When i Press Expand Button

@IBAction func expandPressed(sender: AnyObject) {

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

This is the what i am getting as output, It is covering my next text field. How can i make Address textField move down if the view is expanded?

enter image description here


Solution

  • you can set the textfield frame in the function:

    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
    }
    

    hope help you! This is the result:

    enter image description here