0

I am using iOS 7`s new Dynamic Text feature for the subtitle of a table view row. I have set the UILabel in IB as follows:

enter image description here

This is how I set the contents of the UILabel in code:

NSAttributedString *checkmarkAttributedString = [[NSAttributedString 
      alloc]initWithString:@"☑"];
[detailAttributedString appendAttributedString:checkmarkAttributedString];

This is the result which is not autoshrinked correctly (the font size should be scaled down and the "..." avoided):

enter image description here

How can I get autoshrink to work?

It seems that it works correctly when I do not add the special character (checkmark) at the beginning of the string.

AlexR
  • 5,514
  • 9
  • 75
  • 130

2 Answers2

3

There is a bug in iOS 6 it works fine for iOS 7, In iOS 6 if the text is multilines then it will not shrink.

Nagaraj
  • 802
  • 9
  • 11
2

Not sure but it looks like the Minimum Font Scale has a comma in it. Shouldn't it be 0.4?

Otherwise try this in your cellForRowAtIndexPath method.

MyCustomTableViewCell *cell = [tableview dequeueReusableCellWithIdentifier:identifier];
cell.detailLabel.adjustsFontSizeToFitWidth = YES;
aahrens
  • 5,522
  • 7
  • 39
  • 63
  • The comma is correct (in my region). However, I found out that I am setting the font to the old font styles in code manually. Do you know how to set the font to one of the new Dynamic Text font styles? – AlexR Oct 15 '13 at 13:49
  • Use a system font. Those should support Dynamic Text. So like [UIFont systemFontOfSize:15]; – aahrens Oct 15 '13 at 13:54