What i'm trying to achieve
--------------------------

I have two buttons, `yes/no`. When `yes` is pressed a subview needs to be generated right under it and when `no` is pressed the subview need to disappear(not just hide, but remove itself).

After doing some search i have reached the conclusion that what i need is a dynamic view.

What i tried to do
------------------

I have created the buttons and now i'm trying to write the code for the view, so at the end i will have to connect the buttons to the code.

This is my UIView Class:

```
class FormView: UIView {

override init(frame: CGRect) {
    super.init(frame: frame)
    viewSetup()
}

required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}

private func viewSetup() {
    self.backgroundColor = .red
}
}

```

and this is how i tried to create the view:

```
    var formViewOrigin = selectFormView.frame.origin
    formViewOrigin.y += selectFormView.frame.height

    let formViewWidth = selectFormView.frame.width
    let formViewHeight = selectFormView.frame.height
    let formViewSize = CGSize(width: formViewWidth, height: formViewHeight)

    let myview = FormView(frame: CGRect(origin: formViewOrigin, size: formViewSize))

    myview.leadingAnchor.constraint(equalTo: descriptionLabel.leadingAnchor)
    myview.topAnchor.constraint(equalTo: selectFormView.bottomAnchor, constant: 24)
    myview.trailingAnchor.constraint(equalTo: selectFormView.trailingAnchor)
    myview.bottomAnchor.constraint(equalTo: descriptionTextField.topAnchor, constant: 50)

    let bigView = scrollView.viewWithTag(1)
    bigView!.addSubview(myview)

```

The problem
-----------

The view is being generated, but it is not in the place that i want it to be(right under my buttons), instead it is at the end of the `bigview`. I have tried to change the constraints but i think they don't have any impact, because i also commented them and nothing happened. Does anyone have any idea on why is this happening?

To give you a better visual understading of what i'm trying to do here is an image: [formview](https://i.stack.imgur.com/xq5Tb.png) 

FormView has to appear between `description` and `selectFormView`.

`selectFormView` is the view that contains the buttons.