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添加删除线的更多相关文章

  1. iOS label 添加删除线(删划线)遇到的坑

    1.添加删划线方法遇到的问题 -(void)lastLabelDeal:(NSString *)str1 string:(NSString *)str2 label:(UILabel *)label{ ...

  2. iOS 为label加删除线

    NSString *oldPrice = [NSString stringWithFormat:@"原价 %@",_item.previousPrice.stringValue]; ...

  3. ios Lable 添加删除线

    遇到坑了: NSString *goodsPrice = @"230.39"; NSString *marketPrice = @"299.99"; NSStr ...

  4. Android中TextView添加删除线

    项目中的需求~~~~ 商城中物品的一个本身价格,还有一个就是优惠价格...需要用到一个删除线. public class TestActivity extends Activity { private ...

  5. python 对过时类或方法添加删除线的方法

    class Cat(Animal): def __init__(self): import warnings warnings.warn("Cat类带删除线了", Deprecat ...

  6. [代码]label增加删除线

    UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(20, 60, 100, 30)];    [self.view addSubvi ...

  7. Android: 在 TextView 里使用删除线

    Android: 在 TextView 里使用删除线 分类: Android2014-09-25 13:17 3431人阅读 评论(0) 收藏 举报 以编程的方式添给 TextView 添加删除线: ...

  8. iOS创建带删除线和价钱符号的Label

    效果显示如下: 只需要子类化Label,重写DrawRect()方法即可: #import "MyLabel.h" @implementation MyLabel - (insta ...

  9. iOS · UILabel加删除线

    创建自定义子类DeleteLineLabel,继承自UILabel,然后在自定义子类DeleteLineLabel中 方法一(上下文): - (void)drawRect:(CGRect)rect { ...

随机推荐

  1. 关于jQuery的条件判断问题

    遇到的第一个问题,点击第一行用toggle实现背景的变换,需要在toggle函数里面判断,当下面显示的时候是一个状态,下面不显示的时候是另一个状态,我用了 if($(".check-box& ...

  2. 关于tab选项卡,选项的css问题。

    刚开始的思路是:让上面的选中的选项背景变成白色,让下面的层position:absolute;z-index:-1;top:1px,就能盖得上上面的横线.实践证明,这样是能盖得上,但是单选按钮不能点了 ...

  3. Swift\本地文件管理

    转载自:http://www.coloroud.com/2015/06/01/Swift-File-Manager/ 开头 看来Swift这趟浑水是非干不可,既然如此,那索性就来的彻底吧,来一次全方位 ...

  4. Lucene全文搜索 分组,精确查找,模糊查找

    http://zm603380946.iteye.com/blog/1827318 完全个人理解,如有更好的方法,欢迎一起讨论 LuceneUtils.java package com.zbiti.l ...

  5. 解析GenericOptionsParser

    hadoop源代码分析(4)-org.apache.hadoop.util包-GenericOptionsParser类[原创]   一  准备 hadoop版本:1.0.3,GenericOptio ...

  6. 关于c中的inline

    在c中,为了解决一些频繁调用的小函数大量消耗栈空间或是叫栈内存的问题,特别的引入了inline修饰符,表示为内联函数.栈空间就是指放置程式的局部数据也就是函数内数据的内存空间,在系统下,栈空间是有限的 ...

  7. PAT1015

    A reversible prime in any number system is a prime whose "reverse" in that number system i ...

  8. python插入mysql新值

    #Server Connection to MySQL: import MySQLdb conn = MySQLdb.connect(host= "localhost", user ...

  9. 看unix高级编程时遇到apue.h找不到的问题

    最近学习 Unix 环境高级编程这本书,第一个例子就碰到了问题,下面是解决办法. 一开始看到这本书,刚翻了几页,就觉得对味.按照书中的代码做练习时,编译代码文件提示fatal error: apue. ...

  10. jsp 获取cookie 的值的方法

    Cookie cookies[]=request.getCookies(); //读出用户硬盘上的Cookie,并将所有的Cookie放到一个cookie对象数组里面 Cookie sCookie=n ...