At the time of the preferential price to use the deletion line, but the online deletion line of the same, are big copy small copy, in fact, Apple nsattributedstring can achieve this.
The code is as follows:
NSString *oldprice = @ "¥12345"; Nsuinteger length = [oldprice length]; nsmutableattributedstring *attri = [[Nsmutableattributedstring alloc] initwithstring:oldprice]; [Attri addattribute:nsstrikethroughstyleattributename value:@ (nsunderlinepatternsolid | Nsunderlinestylesingle) Range:nsmakerange (2, length-2)]; [Attri addattribute:nsstrikethroughcolorattributename Value:uicolorfromrgb (0x999999, 1) range:NSMakeRange (2, Length-2)]; [Oldpricelabel Setattributedtext:attri];
Code I think a little bit of iOS knowledge can understand, not much introduced, only for posterity reference. If there are deficiencies, please be more understanding.
Lable first-line experience of strikethrough