objective-cios7uilabelnsattributedstringdynamic-text

UILabel Autoshrink does not work with Dynamic Text and special character


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.


Solution

  • 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;