iOS 为label添加删除线
UILabel *testLabel = [[ UILabel alloc] initWithFrame:CGRectMake(, , , )];
testLabel.numberOfLines = ;
NSString* strText = @"测试画删除线测试画删除线测试画删除线测试画删除线测试画删除线";
NSMutableAttributedString *content = [[NSMutableAttributedString alloc]initWithString:strText];
NSRange contentRange = {,[content length]};
[content addAttribute:NSStrikethroughStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];
testLabel.attributedText = content;
[self.view addSubview:testLabel];
NSFontaAttributeName 字体
NSParagraphStyleAttributeName 段落格式
NSForegroundColorAttributeName 字体颜色
NSBackgroundColorAttributeName 背景眼色
NSStrikethroughSstyleAttributeName 删除线格式
NSStrikethroughColorAttributeName 删除线颜色
NSStrokeWidthAttributeName 删除线宽度
NSUnderlineStyleAttributeName 下划线格式
UILabel *testLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(, , , )];
NSMutableAttributedString *content2 = [[NSMutableAttributedString alloc]initWithString:strText];
testLabel2.numberOfLines = ;
NSRange contentRange2 = {,[content2 length]};
[content2 addAttributes:@{NSStrikethroughStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleSingle],NSStrikethroughColorAttributeName:[UIColor redColor]} range:contentRange2];
testLabel2.attributedText = content2;
[self.view addSubview:testLabel2];
iOS 为label添加删除线的更多相关文章
- iOS label 添加删除线(删划线)遇到的坑
1.添加删划线方法遇到的问题 -(void)lastLabelDeal:(NSString *)str1 string:(NSString *)str2 label:(UILabel *)label{ ...
- iOS 为label加删除线
NSString *oldPrice = [NSString stringWithFormat:@"原价 %@",_item.previousPrice.stringValue]; ...
- ios Lable 添加删除线
遇到坑了: NSString *goodsPrice = @"230.39"; NSString *marketPrice = @"299.99"; NSStr ...
- Android中TextView添加删除线
项目中的需求~~~~ 商城中物品的一个本身价格,还有一个就是优惠价格...需要用到一个删除线. public class TestActivity extends Activity { private ...
- python 对过时类或方法添加删除线的方法
class Cat(Animal): def __init__(self): import warnings warnings.warn("Cat类带删除线了", Deprecat ...
- [代码]label增加删除线
UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(20, 60, 100, 30)]; [self.view addSubvi ...
- Android: 在 TextView 里使用删除线
Android: 在 TextView 里使用删除线 分类: Android2014-09-25 13:17 3431人阅读 评论(0) 收藏 举报 以编程的方式添给 TextView 添加删除线: ...
- iOS创建带删除线和价钱符号的Label
效果显示如下: 只需要子类化Label,重写DrawRect()方法即可: #import "MyLabel.h" @implementation MyLabel - (insta ...
- iOS · UILabel加删除线
创建自定义子类DeleteLineLabel,继承自UILabel,然后在自定义子类DeleteLineLabel中 方法一(上下文): - (void)drawRect:(CGRect)rect { ...
随机推荐
- T-shirts Distribution
T-shirts Distribution time limit per test 1 second memory limit per test 256 megabytes input standar ...
- CSS样式 初学
CSS样式 参考网站: CSS用法:3种 一:直接样式表 如<p style="color:red;">这是一个段落</p> 二:内部样式表 如:<s ...
- Android OpenGL ES .介绍
引自:http://blog.csdn.net/hgl868/article/details/6971624 1. OpenGL ES 简介 Android 3D引擎采用的是OpenGL ES. ...
- OVS - commands
journalctl -t ovs-vswitchd ovs-vsctl show ovs-ofctl show br0 set vlanid ovs-vsctl set port eth0 tag= ...
- 破解MyEclipse2013注册码
1.下载破解工具 http://down8.3987.com:801/2010/Myeclipse_zcj.3987.com.rar 2.打开 找到meclipse安装路径找到plugins文件夹打开 ...
- iOS项目架构 小谈
层级结构,自底向上 持久层(File,Realm,SQLite)<==>网络层(相信每个公司都有自己的网络层吧)==>业务层(ViewModel)==>展示层(View,VC) ...
- ubuntu中安装myeclipse提示Insufficient Memory解决方法
经过查看资料发现出现这个问题的原因是因为计算机中swap分区的内存不足,或者没有创建swap分区,google中http://www.bkjia.com/webzh/1003601.html提供了一种 ...
- Android 系统编译
最近研究了下Android 的编译系统,下面结合编译我们自己的产品 mobot 来对整个编译系统进行必要的介绍,方便大家今 后对默认编译的修改. 先列出几个觉得重要的Make 文件: build/bu ...
- 教你用CSS代码写出的各种形状图形
做网页设计时经常要用到各种形状的图形,对于规则的图形很简单,但是对于不规则的图形,一般我们都是用图片,今天就在这里教大家怎样用css代码写出各种规则不同的图形 1.正方形 #square {width ...
- logstash安装配置
vim /usr/local/logstash/etc/hello_search.conf 输入下面: input { stdin { type => "human" }} ...