1

I have the following code in an app to reduce the size of the font to fit the fixed uiTextView

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

However I understand that contentSize.height no longer works correctly, can anyone help with this?

Many Thanks

sjbuchanan007
  • 111
  • 1
  • 11

1 Answers1

1

I found the answer by doing a bit more digging around Stack Overflow. Answer here Resize font size to fill UITextView?

Thanks to https://stackoverflow.com/users/2025180/stefan-haflidason

and here is the code I used :-

while (((CGSize) [pdThree sizeThatFits:pdThree.frame.size]).height > pdThree.frame.size.height) {
    pdThree.font = [pdThree.font fontWithSize:pdThree.font.pointSize-1];
}
Community
  • 1
  • 1
sjbuchanan007
  • 111
  • 1
  • 11