title: Drawing ruled lines in UITextView
body: <p>In a UITextView I want to draw ruled lines along with the text. For that, I subclass UITextView and overwrite drawRect. Seing a few post on the subject (including on this site), that seems the right way to start.</p>
  
  <p>Here is the loop where I draw the lines:</p>
  
  <pre><code>for (int x=1;x&lt;numberOfLines;x++) {
      yPos=self.font.lineHeight*x+baselineOffset;
      CGContextMoveToPoint(context,self.bounds.origin.x,yPos);
      CGContextAddLineToPoint(context,self.bounds.size.width,yPos);
  }
  </code></pre>
  
  <p>baselineOffset in this code is constant, meaning I step by self.font.lineHeight
  but seeing the picture below (with the slow shifting between the lines and the text) I am obviously not using the right value for incrementing
  the y coordinate (here called yPos). What should I use?</p>
  
  <p>Has anyone got an idea of what could be the problem?</p>
  
  <p>Thank you for any tip.</p>
  
  <p><img src="https://i.stack.imgur.com/wLjTC.png" alt="enter image description here"></p>