Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSStrikethroughStyleAttributeName , How to strike out the string in iOS 10.3?

I have used this line of code before release of iOS 10.3 ,and worked fine.

NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@\n%@",strMRP,strOffer]];

[attributeString addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:12] range:NSMakeRange(0, strMRP.length)];

[attributeString addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:15] range:NSMakeRange(strMRP.length, strOffer.length+1)];

[attributeString addAttribute:NSStrikethroughStyleAttributeName
                        value:[NSNumber numberWithInteger: NSUnderlineStyleDouble]
                        range:NSMakeRange(0,strMRP.length)];

But now it is stopped working ,is there any alternate way to do the strike out ?

like image 554
Kishore Kumar Avatar asked Mar 28 '17 13:03

Kishore Kumar


Video Answer


2 Answers

it is the bug in iOS 10.3 , NSStrikethroughStyleAttributeName (any NSUnderlineStyle cases) is not working any more on iOS SDK 10.3.

if anyone found the updated answer related to this , please inform here, I will update my answer.

Product Version: 10.3

Created: 14-Mar-2017

Originated: 14-Mar-2017

Open Radar Link: http://www.openradar.appspot.com/31034683

Radar status is Currently Open state

you can see the alternate sample also here may be it useful.

like image 110
Anbu.Karthik Avatar answered Oct 21 '22 05:10

Anbu.Karthik


I found one workaround on developer forum, which works for me. Adding of NSBaselineOffsetAttributeName to string attributes fixed this problem :)

like image 38
Anton Gaenko Avatar answered Oct 21 '22 05:10

Anton Gaenko