Underlining in attributed strings doesn't work in a UILabel if the attribute range start is bigger than 0
| Originator: | vladimir | ||
| Number: | rdar://18579919 | Date Originated: | 08-Oct-2014 |
| Status: | Open | Resolved: | No |
| Product: | iOS | Product Version: | 8.0.0-8.0.2 |
| Classification: | UI/Usability | Reproducible: | Always |
Summary:
When setting the title of a button to an attributed string with an underline attribute, the underline will only show if the range of that underline starts at 0. If it starts at any other position, the underline doesn't show. Other attributes work fine in this situation. This also happens in UILabels. Works as expected on iOS 7.
Steps to Reproduce:
1. Create a new single-view iOS Xcode project.
2. Create two buttons.
3. In the viewDidLoad of the view controller, set the attributed titles of the buttons to two different attributed strings. I used the following two strings:
NSMutableAttributedString* range0 = [[NSMutableAttributedString alloc] initWithString:@"Lorem ipsum"];
[range0 addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:NSMakeRange(0, 5)];
NSMutableAttributedString* range1 = [[NSMutableAttributedString alloc] initWithString:@"Lorem ipsum"];
[range1 addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:NSMakeRange(1, 5)];
Expected Results:
In both buttons, the underline will be visible.
Actual Results:
In one of the buttons (the one with the attribute range that starts at a position other than 0) there is no underline at all.
Version:
iOS 8.0.2 (12A405)
Notes:
Configuration:
Reproducible on all devices and simulators
Attachments:
'UnderlineTester.zip' was successfully uploaded.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Test project can be found here: https://www.sendspace.com/file/1poy65