title: Setting a tail indent for a label in swift
body: <p>I am a beginner in iOS and am trying to make a number pad. The problem I am having is that, the text(number display) is too close to the border. As you can see in the picture below.</p>
  
  <p><a href="https://i.stack.imgur.com/Bjdiwm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bjdiwm.png" alt="original numpad"></a></p>
  
  <p>I first tried to use attributedString instead of plain text in the label. But setting it to 1 gives me this. Even setting it to 0.0000000001 does not differ any.</p>
  
  <p><a href="https://i.stack.imgur.com/HPZeKm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HPZeKm.png" alt="bad numpad1"></a>
  <a href="https://i.stack.imgur.com/s2EeEm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s2EeEm.png" alt="bad numpad2"></a></p>
  
  <p>This is my configuration</p>
  
  <p><a href="https://i.stack.imgur.com/x3ZCym.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x3ZCym.png" alt="setting"></a></p>
  
  <p>Since this method does not seem to work, I then tried to use paragraph style. Here is my code</p>
  
  <pre><code>let paragraphStyle = NSMutableParagraphStyle()
  paragraphStyle.tailIndent = -0.1
  let attributes = [NSParagraphStyleAttributeName: paragraphStyle]
  </code></pre>
  
  <p>Then I realized <code>myLabel.attributedText</code> is a <code>NSAttributedString</code>, not <code>NSMutableAttributableString</code>, which means it does not have a <code>addAttribute</code> method. I have not found any way to make <code>myLabel.attributedText</code> a <code>NSMutableAttributableString</code>. So that does not work for me.</p>
  
  <h2>Question</h2>
  
  <p>My question is, how can I give a proper tail indent to my text in the label?</p>
  
  <h2>Update</h2>
  
  <p>I tried this and it does not work.</p>
  
  <pre><code>@IBOutlet weak var display: UILabel! 
      didSet {
          let myString = display.attributedText!.string
          let paragraphStyle = NSMutableParagraphStyle()
          paragraphStyle.tailIndent = -0.0000000001
          let attributes = [NSParagraphStyleAttributeName: paragraphStyle]
          let myMutableAttributedString = NSMutableAttributedString(string: myString, attributes: attributes)
  
          display.attributedText = myMutableAttributedString
      }
  }
  </code></pre>
  
  <p>gives me this
  <a href="https://i.stack.imgur.com/QLB8Nm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QLB8Nm.png" alt="new try"></a></p>