 
         self.contentView.addSubview(self.nameLabel)
         self.contentView.addSubview(self.valueSwitch)
-    }
-
-    fileprivate override func layoutSubviews() {
-        super.layoutSubviews()
-
-        self.nameLabel.frame = CGRect(x: 8, y: 2, width: self.nameLabelWidth, height: self.contentView.bounds.height - 4)
-        self.valueSwitch.frame = CGRect(
-            x: self.nameLabel.frame.maxX + 8,
-            y: (self.contentView.bounds.height - self.valueSwitch.bounds.height) / 2,
-            width: self.contentView.bounds.width - self.nameLabel.frame.maxX - 16,
-            height: self.valueSwitch.bounds.height
-        )
+
+        self.nameLabel.addConstraint(self.nameLabelWidthConstraint)
+        self.nameLabel.addConstraint(forHeight: 50)
+
+        self.contentView.addConstraints([
+            NSLayoutConstraint(topOf: self.nameLabel, to: self.contentView, distance: 2),
+            NSLayoutConstraint(verticalCenterOf: self.nameLabel, to: self.contentView),
+            NSLayoutConstraint(leftOf: self.nameLabel, to: self.contentView, distance: 8),
+
+            NSLayoutConstraint(leftOf: self.valueSwitch, toRightOf: self.nameLabel, distance: 8),
+            NSLayoutConstraint(topOf: self.valueSwitch, to: self.nameLabel),
+            NSLayoutConstraint(bottomOf: self.valueSwitch, to: self.nameLabel),
+            NSLayoutConstraint(rightOf: self.valueSwitch, to: self.contentView, distance: 8),
+        ])
     }
 
     required init?(coder aDecoder: NSCoder) {


        self.contentView.addSubview(self.nameLabel)
        self.contentView.addSubview(self.segmentedControl)
    }

    fileprivate override func layoutSubviews() {
        super.layoutSubviews()

        self.nameLabel.frame = CGRect(x: 8, y: 2, width: self.nameLabelWidth, height: self.contentView.bounds.height - 4)
        self.segmentedControl.frame = CGRect(
            x: self.nameLabel.frame.maxX + 8,
            y: (self.contentView.bounds.height - 30) / 2,
            width: self.contentView.bounds.width - self.nameLabel.frame.maxX - 16,
            height: 30
        )
    }
    
    required init?(coder aDecoder: NSCoder) {

private class BoolFieldTableViewCell: UITableViewCell {
    static let identifier = "BoolField"

    let nameLabel: UILabel
    let valueSwitch = UISwitch()
    private let nameLabelWidthConstraint: NSLayoutConstraint

    var nameLabelWidth: CGFloat {
        get {
            return self.nameLabelWidthConstraint.constant
        }

        set {
            self.nameLabelWidthConstraint.constant = newValue
        }
    }

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        let nameLabel = UILabel()
        self.nameLabel = nameLabel
        self.nameLabelWidthConstraint = NSLayoutConstraint(item: nameLabel, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 100)

        super.init(style: style, reuseIdentifier: reuseIdentifier)

        self.nameLabel.font = FormViewController.font
