title: iOS Swift: UIPickerView Text Alignment
body: <p>Attempting to right/left align the text in two components in a <code>UIPickerView</code>. It's being displayed correctly inside of the selected zone, but the text is overlapping elsewhere. </p>
  
  <p>Any idea what I'm doing wrong here?</p>
  
  <pre><code>func pickerView(pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusingView view: UIView?) -&gt; UIView {
      let pickerLabel = UILabel()
      var titleData: String!
  
    if component == 0 {
        if pickerView.tag == 0 {
            titleData = weightData[row].description
        } else {
            titleData = bodyFatData[row].description
        }
        pickerLabel.textAlignment = .Right
  
    } else {
        titleData = decimalData[row].description
        pickerLabel.textAlignment = .Left
    }
  
    let myTitle = NSAttributedString(string: titleData, attributes: [NSFontAttributeName:UIFont.systemFontOfSize(22.0),NSForegroundColorAttributeName:
  
    UIColor.blackColor()])
        pickerLabel.attributedText = myTitle
  
        return pickerLabel
    }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/xSI9m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xSI9m.png" alt="enter image description here"></a></p>
  
  <p>EDIT:</p>
  
  <p>When I add this line</p>
  
  <p><code>pickerLabel.frame.size = CGSizeMake(165, 26)</code></p>
  
  <p>It does have an effect, but the selected/unselected rows are still misaligned.</p>
  
  <p><a href="https://i.stack.imgur.com/6N44k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6N44k.png" alt="enter image description here"></a></p>