-
-
Save CreatureSurvive/6af1476328d0ad6cad7e7752057aebf7 to your computer and use it in GitHub Desktop.
Size-to-Fit Text in UITextView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define kDefaultFontSize 24.0 | |
myTextView.text = @"Some long string that will be in the UITextView"; | |
myTextView.font = [UIFont systemFontOfSize:kDefaultFontSize]; | |
//setup text resizing check here | |
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++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment