美文网首页
给Label加下划线、中划线ios

给Label加下划线、中划线ios

作者: ios小正太 | 来源:发表于2017-02-17 19:35 被阅读0次

添加中划线:UILabel* strikeLabel = [[UILabelalloc] initWithFrame:(CGRectMake(10,10,50,30))];NSString*textStr = [NSStringstringWithFormat:@"%@元", primeCost];//中划线NSDictionary*attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumbernumberWithInteger:NSUnderlineStyleSingle]};NSMutableAttributedString*attribtStr = [[NSMutableAttributedStringalloc]initWithString:textStr attributes:attribtDic];// 赋值strikeLabel.attributedText = attribtStr;  [self.view addSubview:strikeLabel];

添加下划线:UILabel*underlineLabel = [[UILabelalloc] initWithFrame:(CGRectMake(10,10,50,30))];NSString*textStr = [NSStringstringWithFormat:@"%@元", primeCost];// 下划线NSDictionary*attribtDic = @{NSUnderlineStyleAttributeName: [NSNumbernumberWithInteger:NSUnderlineStyleSingle]};NSMutableAttributedString*attribtStr = [[NSMutableAttributedStringalloc]initWithString:textStr attributes:attribtDic];//赋值underlineLabel.attributedText = attribtStr;  [self.view addSubview:underlineLabel];

相关文章

网友评论

      本文标题:给Label加下划线、中划线ios

      本文链接:https://www.haomeiwen.com/subject/lkilwttx.html