Centering Horizontally using CGRect and Giving Contraint Programatically
<p>I have a UITextField which is programatically created. I tried to center it using <code>UIScreen.mainScreen().bounds.width / 2</code> but it doesn't seem right. What is the proper way of aligning ui item using CGRect? How can I center UITextField horizontally?</p>

<pre><code>    let screenSize: CGRect = UIScreen.mainScreen().bounds
    let screenWidth = screenSize.width
    let screenHeight = screenSize.height

    let textFieldFrame = CGRect(x: screenWidth / 2, y: screenHeight / 2, width: 200.00, height: 40.00)

    let textField = HoshiTextField(frame: textFieldFrame)
    textField.placeholderColor = UIColor.whiteColor()
    textField.borderActiveColor = UIColor.whiteColor()

    self.view.addSubview(textField)
</code></pre>

<hr>

<p>I also have another question. I have <code>@IBOutlet weak var label: UILabel!</code> and together as aligning the above UITextField horizontally, I want to give it a constraint too to keep its distance with the UILabel.</p>

<pre><code>              |        --Label--       |
              |            |           |      I want to center UITextfield
              |            | 20px      |   horizontally and give it a constraint
              |            |           |   to stay 20px below Label 
              |       UITextField      |
</code></pre>