**Explanation:** 

In my ViewController i want to create and adjust a view programmatically depending on a radio button. There is one problem as i create the view and setup the constraint programmatically, one of the labels just disappears and if i continued with that most of the component within the ViewController either disappear and move.

**Pictures:**

[![Before AutoLayout applied](https://i.stack.imgur.com/9BSh5.png)](https://i.stack.imgur.com/9BSh5.png)

[![after AutoLayout applied](https://i.stack.imgur.com/GMT5i.png)](https://i.stack.imgur.com/GMT5i.png)

**Code:**

```
func serviceHoursRadioButtonAction(button: DLRadioButton) {
    if button.currentTitle == "yes" {
        serviceHoursView = UIView()
        if let myView = serviceHoursView {
            myView.backgroundColor = UIColor.lightGrayColor()
            view.addSubview(myView)
            NSLayoutConstraint(item: myView,
                               attribute: .Top,
                               relatedBy: .Equal,
                               toItem: serviceHoursLabel,
                               attribute: .Bottom,
                               multiplier: 1, constant: 10).active = true
            NSLayoutConstraint(item: myView,
                               attribute: .LeftMargin,
                               relatedBy: .Equal,
                               toItem: self.view,
                               attribute: .LeftMargin,
                               multiplier: 1, constant: 0).active = true
            NSLayoutConstraint(item: myView,
                               attribute: .RightMargin,
                               relatedBy: .Equal,
                               toItem: self.view,
                               attribute: .RightMargin,
                               multiplier: 1, constant: 0).active = true
            NSLayoutConstraint(item: myView,
                               attribute: .BottomMargin,
                               relatedBy: .Equal,
                               toItem: self.view,
                               attribute: .BottomMargin,
                               multiplier: 1, constant: 0).active = true

        }

    } else {
        //do nothing, or remove the created view if any.
    }
}

```