@ need to be imported before iOS6 to use nsmutableattributedstring: Coretext.framework frame, but not after iOS6.
-(void) testofnsmutableattributedstringandnsattributedstring{/** *-(void) AddAttribute: (NSString *) Name value: (i d) Value range: (nsrange) range; * Main Method * Name Property name * Value property corresponds to the effect of the range */#pragma mark test data 0 nsstring *tes tstring = @ "nsmutableattributed---0"; UILabel *testlabel = [[UILabel alloc] Initwithframe:cgrectmake (60, 100, 200, 40)]; nsmutableattributedstring * testattristring = [[Nsmutableattributedstring alloc] initwithstring:teststring]; Add strikethrough [testattristring addattribute:nsstrikethroughstyleattributename value:[nsnumber numberWithInt: Nsunderlinestylesingle] Range:nsmakerange (0, testattristring.length)]; Add underscore [testattristring addattribute:nsunderlinestyleattributename value:[nsnumber Numberwithint: Nsunderlinestylesingle] Range:nsmakerange (0, testattristring.length)]; Set font and size of text [testattristring addattribute:nsfontattributename value:[uifont fontwithname:@ "helvetica-bold" size : +] Range: Nsmakerange (0, testattristring.length)]; Set the thickness of the stroke [testattristring addattribute:nsstrokewidthattributename value:[nsnumber Numberwithint: Nsunderlinestyledouble] Range:nsmakerange (0, testattristring.length)]; Label's background color [testattristring addattribute:nsbackgroundcolorattributename value:[uicolor Yellowcolor] Range: Nsmakerange (0, testattristring.length)]; No results have been measured at the moment ..... [Testattristring addattribute:nsverticalglyphformattributename Value:[nsnumber numberWithInt:1] Range:NSMakeRange ( 0, Testattristring.length)]; Label text color (also affects strikethrough and underline color) [testattristring addattribute:nsforegroundcolorattributename Value:[uicolor Redcolor] Range:nsmakerange (0, testattristring.length)]; Testlabel.attributedtext = testattristring; #pragma mark test data 1 NSString *teststring1 = @ "nsmutableattributed---1"; UILabel *testlabel1 = [[UILabel alloc] Initwithframe:cgrectmake (60, 200, 200, 40)]; nsmutableattributedstring * testAttriString1 = [[NsmutableattributedstrinG Alloc] initwithstring:teststring1]; Implement text content color and underline, strikethrough color is not the same//Nsstrokecolorattributename set alone no effect//must be set with Nsstrokewidthattributename [Testattris Tring1 addattribute:nsstrikethroughstyleattributename value:[nsnumber Numberwithint:nsunderlinestylesingle] Range: Nsmakerange (0, testattristring1.length)]; [TestAttriString1 addattribute:nsforegroundcolorattributename Value:[uicolor Redcolor] Range:nsmakerange (0, Testattristring1.length)]; [TestAttriString1 addattribute:nsstrokecolorattributename Value:[uicolor Cyancolor] Range:nsmakerange (0, Testattristring1.length)]; [TestAttriString1 addattribute:nsstrokewidthattributename Value:[nsnumber numberwithint:nsunderlinestyledouble] Range:nsmakerange (0, testattristring1.length)]; Testlabel1.attributedtext = testAttriString1; #pragma mark test Data 2 NSString *teststring2 = @ "nsmutableattributed---2"; UILabel *testlabel2= [[UILabel alloc] Initwithframe:cgrectmake (60, 300, 200, 40)]; Nsmutableattributedstring * testAttriString2 = [[Nsmutableattributedstring alloc] initwithstring:teststring2]; Shadow effect of stroke nsshadow *shadow = [[Nsshadow alloc] init]; [Shadow Setshadowcolor:[uicolor colorwithred:0.053 green:0.088 blue:0.205 alpha:1.000]]; [Shadow setshadowblurradius:4.0]; [Shadow Setshadowoffset:cgsizemake (2, 2)]; [TestAttriString2 addattribute:nsshadowattributename Value:shadow range:nsmakerange (0, [testAttriString2 length])]; Testlabel2.backgroundcolor = [Uicolor Clearcolor]; Testlabel2.attributedtext = testAttriString2; [Self.view Addsubview:testlabel]; [Self.view Addsubview:testlabel1]; [Self.view Addsubview:testlabel2];}