Use of Rich text:
Price Rich Text
NSString *string = [NSString stringwithformat:@ "¥1805646.31"];
nsmutableattributedstring *str = [[Nsmutableattributedstring alloc] initwithstring:string];
[Str addattribute:nsfontattributename value:[uifont systemfontofsize:15] Range:nsmakerange (1, string.length-3)];
Self.priceLabel.attributedText = str;
Strikethrough on the original price
NSString *oldstring = [NSString stringwithformat:@ "¥2005646.31"];
nsmutableattributedstring *oldstr = [[Nsmutableattributedstring alloc] initwithstring:oldstring];
[Oldstr addattribute:nsstrikethroughstyleattributename value:@1 range:nsmakerange (0, oldString.length)];
Self.oldPrice.attributedText = Oldstr;
The effect is as follows:
--------------------Various Styles---------------------
Nsfontattributename set font properties, default: Font: Helvetica (Neue) font size: 12NSForegroundColorAttributeNam set Font color, value is Uicolo R object, default value is black Nsbackgroundcolorattributename sets the region background color of the font, the value is Uicolor object, the default value is nil, the transparent color nsligatureattributename set the connection The NSNumber object (integer), 0 for no conjoined characters, 1 for the default conjoined character Nskernattributename to set the character spacing, the value is NSNumber object (integer), the positive spacing is widened, and the negative spacing narrows Nsstrikethroughstyleattributename set Strikethrough, value is NSNumber object (integer) nsstrikethroughcolorattributename set strikethrough color, value is Uicolor object, The default value is black Nsunderlinestyleattributename set underscore, value is NSNumber object (integer), enumeration value in constant Nsunderlinestyle, Similar to strikethrough nsunderlinecolorattributename sets the underline color, the value is the Uicolor object, the default value is black Nsstrokewidthattributename set the stroke width, the value is Nsnumb Er object (integer), negative fill effect, positive hollow effect nsstrokecolorattributename fill part of color, not font color, value is Uicolor object Nsshadowattributename set Set the Shadow property, the value is Nsshadow object Nstexteffectattributename sets the text special effect, takes the value to NSString object, currently only the plate printing effect is available: Nsbaselineoffsetattributenam E Set the baseline offset value to NSNumber (float), positive offset, negative bias nsobliquenessAttributeName set the glyph inclination, with a value of nsnumber (float), positive to the right, negative to the left Nsexpansionattributename set the text transverse stretch property, with a value of NSNumber (fl OAT), positive values stretch text horizontally, negative values compress text Nswritingdirectionattributename set the direction of writing, write from left to right, or write from right to left Nsverticalglyphformattributename Set the text layout direction, the value is NSNumber object (integer), 0 for horizontal text, 1 for vertical text Nslinkattributename set link properties, click the browser to open the specified URL address nsattachmentattri Butename Set the text attachment, the value is Nstextattachment object, commonly used in the text picture mix nsparagraphstyleattributename Sets the text paragraph typesetting format, takes the value to Nsparagraphstyle Object
IOS Rich Text Style summary