2017-07-03 3 views
-1

Ich arbeite an einem attributierten String-Format. Ich muss strike out in vorhandene NSMutableAttributed String hinzufügen. Ist das im unten angegebenen Beispiel möglich.Hinzufügen von Attribut in vorhandenen NSMutableAttributed String

First Task For Bhasin 
30 Jun 2017 12:05 PM till 30 Jun 2017 01:05 PM{ 
NSBackgroundColor = "<CGColor 0x6100000934c0> [<CGColorSpace 0x6080000303c0> (kCGColorSpaceICCBased; kCGColorSpaceModelMonochrome; Generic Gray Gamma 2.2 Profile; extended range)] (0 0)"; 
NSColor = "<CGColor 0x6180002a2ac0> [<CGColorSpace 0x610000230920> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; sRGB IEC61966-2.1; extended range)] (1 0 0 1)"; 
NSFont = "<UICTFont: 0x7fac5476a0b0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 15.00pt"; 
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n 28L,\n 56L,\n 84L,\n 112L,\n 140L,\n 168L,\n 196L,\n 224L,\n 252L,\n 280L,\n 308L,\n 336L\n), DefaultTabInterval 0, Blocks (\n), Lists (\n), BaseWritingDirection -1, HyphenationFactor 0, TighteningForTruncation NO, HeaderLevel 0"; 
} 

Jede Hilfe wird

+0

Fügen Sie den Code von 'attributedString' – Subramanian

+0

@Subramanian, ich bin mit DAAttributedStringFormatter. Ich möchte hinzufügen strike out – gurmandeep

+0

Fügen Sie die Antwort zu konvertieren 'NSAttributedString' in' NSMutableAttributedString' und Hinzufügen der Streik durch Attribut. – Subramanian

Antwort

1

attributedString ist die bestehende NSMutableAttributedString geschätzt.

Objective C

konvertieren NSAttributedString zu NSMutableAttributedString

NSMutableAttributedString *attributedString = [NSMutableAttributedString alloc]initWithAttributedString:<#Your String Here#>]; 

hinzufügen Strikethrough Attribut

[attributedString addAttributes:@{ NSStrikethroughStyleAttributeName : [NSNumber numberWithInteger:NSUnderlineStyleSingle]} range:NSMakeRange(x, y)]; 

x = Startindex, y = Länge der Zeichenfolge.

Swift:

attributedString.addAttributes([NSStrikethroughStyleAttributeName: NSNumber(integer: NSUnderlineStyle.StyleSingle.rawValue)], range: NSMakeRange(x, y)) 

konvertieren NSAttributedString zu NSMutableAttributedString

let attributedString:NSMutableAttributedString = NSMutableAttributedString(attributedString: <#NSAttributedString#>) 
+0

Down vote ohne Kommentar wird nicht helfen – Subramanian

+0

Ich bin auf der Suche nach Obj c code. – gurmandeep

+0

Bereits hinzugefügt. Und etikettiere deine Frage an Objective c. So wird es den Leuten helfen, die bevorzugte Sprache zu identifizieren. – Subramanian

Verwandte Themen