Reputation: 2002
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
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