thavasidurai
thavasidurai

Reputation: 2002

How to increase UITextView font size when UITextView's size increases

I am developing an app which has a feature adding TextView dynamically, increasing and decreasing its size when we are dragging it.

I can adjust the text view size according to the number of characters by setting TextView's content size to TextView's size.

When dragging the TextView corners, I increase the size of TextView. I can do this successfully.

When I am dragging TextView's corners, its size is increasing, but font size is not increasing. Is there any way to increase or decrease TextView font size automatically when TextView size increases?

Upvotes: 2

Views: 1735

Answers (1)

user1829646
user1829646

Reputation:

Try the following code hope it helps.i found from the Link.

#define kDefaultFontSize 24.0


if (myTextView.contentSize.height > myTextView.frame.size.height) {
    int fontIncrement = 1;
    while (myTextView.contentSize.height > myTextView.frame.size.height) {
        myTextView.font = [UIFont systemFontOfSize:kDefaultFontSize-fontIncrement];
        fontIncrement++;
    }
}

Upvotes: 2

Related Questions