IOS development to Label underlined, underlined

Introduction:

When we are doing some shopping class APP or commodity display class APP, we often encounter some kind of discount or buy goods scene. And in order to attract customers, businesses generally discount the current price and the price of goods at the same time show, for comparison, at this time there was a display of the original price of the label added underlined or underlined demand.
we refer to the donkey mother’s home page:
IOS development to Label underlined, underlined
donkey mother home – in the following code directly on the line:

Underline in addition:
UILabel * strikeLabel = [[UILabel alloc] initWithFrame: (CGRectMake (10, 10, 50, 30))]; NSString *textStr = [NSString stringWithFormat:@ "% @ yuan", primeCost] NSDictionary *attribtDic; / / underlined = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]}; NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic]; / / strikeLabel.attributedText = attribtStr [self.view addSubview: assignment; strikeLabel];
Add underline:
UILabel *underlineLabel = [[UILabel alloc] initWithFrame: (CGRectMake (10, 10, 50, 30))]; NSString *textStr = [NSString stringWithFormat:@ "% @ yuan", primeCost] NSDictionary *attribtDic = @{NSUnderlineStyleAttributeName:; / / underline [NSNumber numberWithInteger:NSUnderlineStyleSingle]}; NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic]; / / underlineLabel.attributedText = attribtStr [self.view addSubview: assignment; underlineLabel];

The results are as follows:

IOS development to Label underlined, underlined
renderings

Personal blog: LiCheng blog