I have a UITextField
on a table view cell, and when it's text becomes too long I would like the font size to decrease. I want to make it very clear that I am talking about a UITextField
, not a UILabel
or a UITextView
. The reason I say this is because I have seen this question pop up several times and the answers were all based on UILabel
instead of UITextField
. For example, someone asked "I can't get my UITextField
to autoshrink" and the answer was "make sure it's numberOfLines
is set to 1
". To the best of my knowledge, a UITextField
does not even have that property and is a single line control.
I have tried:
- in IB setting the font to system 14.0,
minFontSize
to 7 and checking the "adjust to fit" box
- in code in
tableView:cellForRowAtIndexPath:
ptCell.name.font = [UIFont systemFontOfSize: 14.0];
ptCell.name.adjustsFontSizeToFitWidth = YES;
ptCell.name.minimumFontSize = 7.0;
but neither of these have worked. By that I mean that instead of the text shrinking it truncates the tail.
Does anyone know what I am missing? Presumably this should work because I have seen other questions complaining that it is doing that when the user does not want it to.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…