2

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

Jayesh Gyanchandani
  • 305
  • 2
  • 6
  • 16

1 Answers1

3

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

Community
  • 1
  • 1
fzh
  • 688
  • 1
  • 6
  • 14
  • 1
    you could animate it with this, too... `UIView.animate(withDuration: 1.0) { // your code here } ` – Adrian Oct 19 '16 at 13:14