Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found a solution. When handling the notification you need to walk the attributes and look for the text styles and update the font:</p> <pre><code>- (void)preferredContentSizeChanged:(NSNotification *)aNotification { UITextView *textView = &lt;the text view holding your attributed text&gt; NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithAttributedString:textView.attributedText]; NSRange range = NSMakeRange(0, attributedString.length - 1); // Walk the string's attributes [attributedString enumerateAttributesInRange:range options:NSAttributedStringEnumerationReverse usingBlock: ^(NSDictionary *attributes, NSRange range, BOOL *stop) { // Find the font descriptor which is based on the old font size change NSMutableDictionary *mutableAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes]; UIFont *font = mutableAttributes[@"NSFont"]; UIFontDescriptor *fontDescriptor = font.fontDescriptor; // Get the text style and get a new font descriptor based on the style and update font size id styleAttribute = [fontDescriptor objectForKey:UIFontDescriptorTextStyleAttribute]; UIFontDescriptor *newFontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle:styleAttribute]; // Get the new font from the new font descriptor and update the font attribute over the range UIFont *newFont = [UIFont fontWithDescriptor:newFontDescriptor size:0.0]; [attributedString addAttribute:NSFontAttributeName value:newFont range:range]; }]; textView.attributedText = attributedString; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload