apply strike through on Special character Rp‎ 4.752.000

apply strike through on Special character Rp‎ 4.752.000 it will be Rp 4.752.000. when I applying strike to this it will not work but when I apply to normal string it's working properly.



let attributeString = NSMutableAttributedString(string: decodedString, attributes: [ NSParagraphStyleAttributeName: style ]) attributeString.addAttribute(NSStrikethroughStyleAttributeName, value: 2, range: NSRange(location: 0, length: attributeString.length))


oldpricenameLabel.attributedText = attributeString

As far as I tested, `NSStrikethroughStyleAttributeName` works as expected for "Rp‎ 4.752.000", and it shows as:

Rp‎ 4.752.000


Can you show a complete code which can reproduce your issue on the Playground?

When you write, Rp‎


do you mean the unicode U+20B9 ₹


Is it this ₹ that is not strikedout ?


Tested the following in an App on simulator, XCode 8.3 ; that works:


        let decodedString = "₹ 4.752.000"
    
        var style = [NSStrikethroughStyleAttributeName: 2]
        let attributeString = NSMutableAttributedString(string: decodedString, attributes: style)
       
        testField.attributedText = attributeString


How did you define style ?


If I do later


        style = [:]
        let attributeString2 = NSMutableAttributedString(string: decodedString, attributes: style)
        label.attributedText = attributeString2

label is unstriked

when i use this text


"Rp 514.800"

it never striked?

"Rp 514.800" this will never striked

I tested and it works.


As asked already, can you post the complete playground, for testing. Otherwise, it is not possible to reproduce your problem.

let decodedString = "Rp 514.800"

var style = [NSStrikethroughStyleAttributeName: 2]

let attributeString = NSMutableAttributedString(string: decodedString, attributes: style)


This will not work

Tested on the Playground (Xcode 8.3.3)

import UIKit

let oldpricenameLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 320, height: 120))
let decodedString = "Rp 514.800"
var style = [NSStrikethroughStyleAttributeName: 2]
let attributeString = NSMutableAttributedString(string: decodedString, attributes: style)
oldpricenameLabel.attributedText = attributeString

Quick Look for `oldpricenameLabel` shows similar to this:

Rp 514.800


What do you mean by This will not work ?

Yes, this will not work if I entered another text it will strike but when I put "Rp 514.800" it will not work doesn't know why. I am so confused

It seems you are not reading the replies.


Can you please post the complete code of your playground ? Otherwise, it is impossible to help. If you do not want to post the code, please close this thread.


Note : it probably works also for you. But, in playground, the formatted result (strikedout) only shows when you click on the eye at the end of the line, not in the line itself. The eye appears when you hover the mouse above the line of text.

I am not asking you any yes-no questions, just waiting for your explanation what this will not work means.


If you really want to be helped, please try to write what you mean by not work. Showing your full code would be the best thing than any other words just repeating not work.

let decodedString = "Rp 514.800"

var style = [NSStrikethroughStyleAttributeName: 2]


let attributeString = NSMutableAttributedString(string: decodedString, attributes: style)

oldpricenameLabel.attributedText = attributeString

oldpricenameLabel.backgroundColor = UIColor.yellow

productView.addSubview(oldpricenameLabel)

this code not working

let decodedString = "Rp 514.800"

var style = [NSStrikethroughStyleAttributeName: 2]

let attributeString = NSMutableAttributedString(string: decodedString, attributes: style)

oldpricenameLabel.attributedText = attributeString

oldpricenameLabel.backgroundColor = UIColor.yellow

productView.addSubview(oldpricenameLabel)

this code not working

Tested on the Playground of Xcode 8.3.3.


import UIKit

let oldpricenameLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 320, height: 120))
let productView = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 120))

let decodedString = "Rp 514.800"
var style = [NSStrikethroughStyleAttributeName: 2]
let attributeString = NSMutableAttributedString(string: decodedString, attributes: style)
oldpricenameLabel.attributedText = attributeString
oldpricenameLabel.backgroundColor = UIColor.yellow
productView.addSubview(oldpricenameLabel)

With Quick Look into `productView`, I get something like this:





Rp 514.800




Seems this code acutally works.


Please show enough code to reproduce your issue. I believe you can try with your Playground.

apply strike through on Special character Rp‎ 4.752.000
 
 
Q