I try to underline part of a string, for example, a 'string' part in 'test string' string. I'm using NSMutableAttributedString
and my solution was working well on iOS7
.
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]
initWithString:@"test string"];
[attributedString addAttribute:NSUnderlineStyleAttributeName
value:@(NSUnderlineStyleSingle)
range:NSMakeRange(5, 6)];
myLabel.attributedText = attributedString;
The problem is that my solution is not working in iOS8
anymore. After spending an hour on testing multiple variants of NSMutableAttributedString
, I found out that this solution works only when range starts with 0 (length can differ). What is the reason for that? How can I workaround this?