博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS label中间加横线的实现
阅读量:7128 次
发布时间:2019-06-28

本文共 710 字,大约阅读时间需要 2 分钟。

hot3.png

###iOS label中间加横线的实现 很多时候,我们需要在label文字中间加横线,就像超市打折商品的价格表一样 打折商品价格

这里我们需要给label做一个处理,代码如下:

- (void)labelText {    self.label = [[UILabel alloc] initWithFrame:CGRectMake(100, 90, 200, 40)];    NSString *textStr = @"1029元";    // 中线 NSStrikethroughStyleAttributeName    // 下划线 NSUnderlineStyleAttributeName    NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};    NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];       // 赋值    self.label.attributedText = attribtStr;    [self.view addSubview:self.label];    }

这样就可以实现label中间加横线的效果。

转载于:https://my.oschina.net/ozawa4865/blog/701297

你可能感兴趣的文章
人生苦短,我用Python(目录)
查看>>
NYOJ 589 糖果
查看>>
xorm
查看>>
算法知识目录整理
查看>>
Zookeeper原理架构
查看>>
css 边框使用
查看>>
SpringBoot集成redisson分布式锁
查看>>
ubuntu ufw防火墙
查看>>
UWP VirtualizedVariableSizedGridView 支持可虚拟化可变大小Item的View(二)
查看>>
perl的匿名引用
查看>>
git 命令总结
查看>>
eclipse 如何运行mavenWeb项目
查看>>
小程序的tab标签实现效果
查看>>
javascript中使用new与不使用实例化对象的区别
查看>>
Excel lastindex of a substring
查看>>
【转】JAVA反射与注解
查看>>
【Python 数据分析】pandas模块
查看>>
微信小程序--兼容
查看>>
【php+uploadify3.2】上传按钮点击一点反应都没有,原因
查看>>
react 使用 moment 进行 日期格式化
查看>>