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. ActionResult的其它返回值

    我们上边所看到的Action都是return View();我们可以看作这个返回值用于解析一个aspx文件.而它的返回类型是ActionResult如 public ActionResult Inde ...

  2. Spring Boot 系列教程16-数据国际化

    internationalization(i18n) 国际化(internationalization)是设计和制造容易适应不同区域要求的产品的一种方式. 它要求从产品中抽离所有地域语言,国家/地区和 ...

  3. 最小点集覆盖/HDU2119

    题目连接 先试一下题/?/ 最小点集覆盖=最大匹配 /*根据i.j建图,跑一边最大匹配 */ #include<cstdio> #include<cstring> using ...

  4. linux 下载安装tomcat

    1.下载tomcat 2.tar -zxvf apache-tomcat-7.0.67.tar.gz 3.cd bin目录  启动  ./startup.sh [root@fuyuanming bin ...

  5. 学习笔记——Windows下cocos2d-x,eclipse中自编译

    cocos2d-x创建的安卓项目导入eclipse后. 在项目属性中配置Builders. 在eclipse编译还需要配置相应的变量,即后面提到的cygwin编译中要添加的变量. D:/cygdriv ...

  6. 转:LoadRunner中参数化技术详解

    LoadRunner中参数化技术详解 LoadRunner在录制脚本的时候,只是忠实的记录了所有从客户端发送到服务器的数据,而在进行性能测试的时候,为了更接近真实的模拟现实应用,对于某些信息需要每次提 ...

  7. The Accumulation of Capital

    The Accumulation of Capital ---- by *Adam Smith Capitals are increased by parsimony, and diminished ...

  8. VIJOS P1081 野生动物园 SBT、划分树模板

    [描述] cjBBteam拥有一个很大的野生动物园.这个动物园坐落在一个狭长的山谷内,这个区域从南到北被划分成N个区域,每个区域都饲养着一头狮子.这些狮子从北到南编号为1,2,3,…,N.每头狮子都有 ...

  9. 剑指offer之有序二维数组查找

    大多数人注意到元素是行列有序的,会马上想到对每行(或列)进行二分查找,每行(或列)需要logN时间,N行(或列)共需要NlogN时间,很容易写出如下代码 1 2 3 4 5 6 7 8 9 10 11 ...

  10. source.list

    deb http://www.anheng.com.cn/debian/ squeeze maindeb-src http://www.anheng.com.cn/debian/ squeeze ma ...