NSStrikethroughStyleAttributeName is not working on device on iOS 10.3, but it works on simulator...
any thoughts ?
NSStrikethroughStyleAttributeName is not working on device on iOS 10.3, but it works on simulator...
any thoughts ?
I am seeing the same behaviour as you've described on iOS 10.3 beta and tvOS 10.2 beta that NSStrikethroughStyleAttributeName doesn't work on the devices, but works just fine in the simulator. That said I couldn't reproduce this behaviour in a very simple demo project.
So simple attributed strings with one styling for the whole string work, but adding a strike through to a part of a string only doesn't get rendered. I could reproduce this in a small demo project and filled a radar (30671850).
Can't work on iOS10.3 simulator either.Now we are considring to draw a line.
It seems that you should set the attribute of the part that you don't want render to @(NSUnderlineStyleNone) at the same time.Things hanppend on iOS8.3.Hope it can help.
10.3 beta 5 is affected too. NSStrikethroughStyleAttributeName is not working anymore.
If this can help, after some tests on a playground with Xcode version 8.3 beta 4 (8W143q), it seems not to work only if a string is partially marked with a strikethrough attribute
i just found that Chinese characters strings does not even work in the simulator....i did submit a bug in apple bug reporter...no replies..
Workaround for specific scenarios can be found here:
http://stackoverflow.com/questions/43074652/ios-10-3-nsstrikethroughstyleattributename-is-not-rendered-if-applied-to-a-sub
Not fixed in official version. This realy *****!
Apple please fix this ASAP!
try addAttribute: NSBaselineOffsetAttributeName
it works & thx a lot
Its really a big problem.
The upgrade ios10.3.1, this problem is still not processing, apple is not going to fix the bug
It works for me. Thank you very much!
Can you show me how did you fix it with NSBaselineOffsetAttributeName?
thx
Try to wrap the NSUnderlineStyle enum in an NSNumber. It worked for me.
Example: attributes[NSStrikethroughStyleAttributeName] = NSNumber(value: NSUnderlineStyle.styleSingle.rawValue)
Add `NSBaselineOffsetAttributeName` to your attributes dictionary. The associated value needs to be an NSNumber containing a float.
The value will determine where your strikethrough appears in the text. (The default value is `0.0`; you'll need to change it to something else. I set this one to `1.5` and it seems to be about centered to the appended text, which doesn't have any strikethrough.)
Here's how I set up the attributes dictionary for the strikethrough string part in Swift 3.1.
let lineString = String(repeating: "\u{00A0}", count: numCharsToRepeat)
let lineStringAttributes: [String:Any] = [
NSBaselineOffsetAttributeName : NSNumber(floatLiteral: 1.5),
NSStrikethroughStyleAttributeName : 1,
]
let attributedLineString = NSMutableAttributedString(string: lineString, attributes: lineStringAttributes)
// then I appended the line string to a prior attributed string that didn't use strikethrough - all worked fine!As a side note, I wanted to create a line using the strikethrough, rather than actually striking through letters. It wouldn't work with a space (`" "`), but it did work with a Unicode Non-Breaking Space: `"\u{00A0}"`, as shown in line 1 of my code example.