How to change the font size of text in UITextView dynamically in iPhone
<p>I have a fixed size UITextView say width and height of 150,150.</p>

<p>The purpose is to display the thought of the day. Please note the size need to remain constant and I cant change it.</p>

<p>Now The length of the thought string varies with respect to thought. What I want to do is change the size of font of the text to make sure it dont show any empty space in UITextView if length is small or it dont show the scroll if its bigger.</p>

<p>So how to vary the font of UITextView according to the length of thought string.</p>

<p>What is wrong with the following code:</p>

<pre><code>CGSize size;
    BOOL run=TRUE;
    CGSize txtViewSize = self.txt_tipView.frame.size;
    while(run){

     size = [self.txt_tipView.text sizeWithFont:[UIFont systemFontOfSize: currentSize] constrainedToSize:txtViewSize lineBreakMode:UILineBreakModeWordWrap];
     if((size.width&lt;=txtViewSize.width) &amp;&amp; (size.height&lt;=txtViewSize.height))
      run = FALSE;
     else
      currentSize--;
    }
    self.txt_tipView.font = [UIFont fontWithName:@"Helvetica" size:currentSize];//[UIFont boldSystemFontOfSize:12];
</code></pre>

<p>What happens is the size of the text in TextView is always 60. That is each line has only one word.</p>
