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

4

1 回答 1

1

通过对 Stack Overflow 进行更多挖掘,我找到了答案。在这里回答Resize font size to fill UITextView?

感谢https://stackoverflow.com/users/2025180/stefan-haflidason

这是我使用的代码:-

while (((CGSize) [pdThree sizeThatFits:pdThree.frame.size]).height > pdThree.frame.size.height) {
    pdThree.font = [pdThree.font fontWithSize:pdThree.font.pointSize-1];
}
于 2014-06-12T06:35:51.910 回答