AliSoftware / OHAttributedLabel

UILabel that supports NSAttributedString
https://github.com/AliSoftware/OHAttributedLabel/wiki
1.51k stars 344 forks source link

Support strikethrough (NSStrikethroughStyleAttributeName) #117

Open gardnermj opened 11 years ago

gardnermj commented 11 years ago

Strikethrough works in UILabel (using NSStrikethroughStyleAttributeName = NSUnderlineStyleSingle), but doesn't seem to work in OHAttributedLabel.

AliSoftware commented 11 years ago

Are you sure that the CoreText framework support this attribute?

As OHAttributedLabel is based on CoreText (because it is the only framework, available since iOS 3.2/4.0+, that can draw attributed strings before iOS6 added support for them in UIKit) and not on the newly introduced UIKit methods, if attributes not supported by CoreText itself are used, you won't see their effect.

I'll make some tests anyway with this attribute, but can you tell the code you did try on your own? Thx

AliSoftware commented 11 years ago

After some digging, I confirm that NSStrikethroughStyleAttributeName is only supported on UIKit (and on OSX) but not by CoreText on iOS.

Unfortunately I won't have time soon to write anything to work around this CoreText limitation and add support for this attribute, but feel free to try yourself and propose a pull request. I saw some interesting code from Cocoanetics (see end of the page) that you can use for inspiration to implement this strikethru yourself, as Apple didn't feel in the mood to support it itself in CoreText…

gardnermj commented 11 years ago

Ah, that's unfortunate. Thanks for the pointer; I don't know if I'll have time to implement it either, but I'll let you know if I do.