Note that there are some explanatory texts on larger screens.

plurals
  1. POAttributed string with NSLinkAttribute does not render on the iPhone
    primarykey
    data
    text
    <p>We have an attributed string with 3 components, two are basic strings, the third is a link. The string is being rendered by a UITextView. Strangely, the link is invisible on the iPhone, yet renders fine on the iPad. The behavior is consistent regardless of simulator or actual phone.</p> <p>Attempting to change the color of the link has no effect. Interestingly, setting the underline color will show the underline... but the text is still invisible.</p> <p>iOS 7, Xcode 5</p> <p>Here is our code:</p> <pre><code>// put together our text for the about view, includes link to Facebook UIFont *font = [UIFont fontWithName:@"Sansation_Bold_Italic" size:aboutText.font.pointSize]; UIFont *linkFont = [UIFont fontWithName:@"Sansation_Italic" size:aboutText.font.pointSize]; NSMutableDictionary* linkAttributes = [[NSMutableDictionary alloc] init]; [linkAttributes setObject:@"https://www.facebook.com/App" forKey:NSLinkAttributeName]; [linkAttributes setObject:[NSNumber numberWithInt:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName]; [linkAttributes setObject:[UIColor blueColor] forKey:NSStrokeColorAttributeName]; [linkAttributes setObject:[UIColor blueColor] forKey:NSUnderlineColorAttributeName]; [linkAttributes setObject:linkFont forKey:NSFontAttributeName]; NSAttributedString* link = [[NSAttributedString alloc] initWithString:@"Facebook" attributes:linkAttributes]; NSMutableAttributedString* mas = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"ABOUTMSG1", nil)]; [mas appendAttributedString:link]; [mas appendAttributedString:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"ABOUTMSG2", nil)]]; [aboutText setAttributedText:mas]; </code></pre> <p>iPhone</p> <p><img src="https://i.stack.imgur.com/KtmAO.png" alt="iPhone result"></p> <p>iPad</p> <p><img src="https://i.stack.imgur.com/JxN7y.png" alt="iPad result"></p> <p>Any thoughts on why the link is not rendering on the iPhone?</p>
    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. 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