Since iOS7 new Nstextstorge is a subclass of nsmutableattributedstring, use good nstextstorage, First of all, to learn nsmutableattributedstring and nsattributedstring.
As a personal understanding, nsattributedstring is a string with attributes that gives you the flexibility to manipulate and render multiple styles of literal data.
Alignment//Alignment
Firstlineheadindent//First line Indent
Headindent//Indent
Tailindent//Trailing indent
Linebreakmode//Break method
Maximumlineheight//MAX row height
Minimumlineheight//Minimum row height
LineSpacing//Line spacing
Paragraphspacing//Segment Distance
Paragraphspacingbefore//Segment head space
Basewritingdirection//sentence direction
Lineheightmultiple//variable row height, multiply factor.
Hyphenationfactor//Hyphen Property
NSString *const nsforegroundcolorattributename;//value is uicolor, font color, default is black.
NSString *const nsbackgroundcolorattributename;//value is uicolor, font background color, default is not.
NSString *const nsligatureattributename;//value is integer nsnumber, hyphenation properties, general Chinese can not be used, in English may appear in the case of adjacent letters pen. 0 is not a pen, 1 is the default pen, and the default value, 2 is not supported on iOS.
NSString *const nskernattributename;//value is a floating-point number NSNumber, the Kerning property, the default value is 0.
NSString *const nsstrikethroughstyleattributename;//value is integer nsnumber, the desired value is
enum {
Nsunderlinestylenone = 0x00,
Nsunderlinestylesingle = 0x01,
}; Set strikethrough.
NSString *const nsunderlinestyleattributename;//Ibid. Sets the underline.
The NSString *const nsstrokecolorattributename;//value is Uicolor, the default value is nil, and the property set is the same as Foregroundcolor.
NSString *const nsstrokewidthattributename;//value is a floating-point number nsnumber. Sets the thickness of the drawing.
NSString *const nsshadowattributename;//value is Nsshadow, sets the shadow of the picture, and the default value is nil.
NSString *const nsverticalglyphformattributename;//value for integer nsnumber,0 is the horizontal layout of the word, 1 is the vertical typesetting of the word.
Example code:
Add Strikethrough on label
<span style= "Font-family:comic Sans ms;font-size:18px;" > UILabel * label = [[UILabel alloc]initwithframe:cgrectmake (+, +, +)];
Label.text = @ "zuoyou1314";
nsmutableattributedstring * str = [[nsmutableattributedstring alloc] initwithstring:@ "zuoyou1314"];
[Str addattribute:nsstrikethroughstyleattributename value:[nsnumber Numberwithint:nsunderlinestylesingle] Range: Nsmakerange (0, Str.length)];
Label.attributedtext = str;
[Self.window addsubview:label];</span>
Set underline
nsmutableattributedstring *attstring = [[Nsmutableattributedstring alloc] initwithstring:@ "Some String"];
[Attstring AddAttribute: (nsstring*) kctunderlinestyleattributename value:[nsnumber numberWithInt: Kctunderlinestylesingle] Range: (nsrange) {0,[attstring length]}];
Self.myLabel.attributedText = attstring;