title: iOS Drawing text in the centre of shapes
body: <p>I'm trying to draw text in the centre of shapes in iOS, an example would be Microsoft Office's insert shape see: <a href="https://www.dropbox.com/s/cgqyyuvy6hcv5g8/Screenshot%202014-01-21%2013.48.17.png" rel="nofollow noreferrer">https://www.dropbox.com/s/cgqyyuvy6hcv5g8/Screenshot%202014-01-21%2013.48.17.png</a></p>
  <p>I have an array of coordinates that are used to form the shape, which works fine for creating the actual shape.</p>
  <p>My first tactic was following this stackoverflow question: <a href="https://stackoverflow.com/questions/20476684/core-text-with-asymmetric-shape-on-ios">Core Text With Asymmetric Shape on iOS</a> however I can only get it to draw the text at the bottom of the shape. Is there any way to centre the text vertically and horizontally?</p>
  <p>I then had a look at the new TextKit but I got stuck with how to subclass <code>NSTextContainer</code> to accept either a <code>CGPath</code> or an array of coordinates to create the text container to draw inside.</p>
  <p>My backup solution is to use Core Text to draw the text at the centre coordinate of a shape, however this will cause the text to draw outside of the shape on some shapes such as a right angled triangle.</p>
  <p>Alternatively, are there any other methods I could use to get some text somewhat in the centre of a shape?</p>