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. iOS UIScrollView偏移量属性

    contentSize: The size of the content view. 其实就是scrollview可以滚动的区域,比如frame = (0 ,0 ,320 ,480) contentS ...

  2. 50条规则提高PHP开发提高效率技巧

    0.用单引号代替双引号来包含字符串,这样做会更快一些.因为PHP会在双引号包围的字符串中搜寻变量,单引号则不会,注意:只有echo能这么做,它是一种可以把多个字符串当作 参数的“函数”(译注:PHP手 ...

  3. UICollectionView 浅析

    什么是UICollectionView UICollectionView是一种新的数据展示方式,简单来说可以把他理解成多列的UITableView(请一定注意这是UICollectionView的最最 ...

  4. python 第三方库下载

    C:\Python27\Scripts 路径下: easy_install.exe: C:\Python27\Scripts>easy_install.exe pycrypto pip.exe: ...

  5. HDU 5240 Exam

    The 2015 ACM-ICPC China Shanghai Metropolitan Programming Contest 2015ACM-ICPC上海大都会赛 签到题 #include< ...

  6. MFC设置窗体大小SetWindowPos

    SetWindowPos(NULL,0,0,200,300,SWP_NOMOVE); 表示不考虑(0,0),仅仅将大小改为200x300,位置不变    SetWindowPos(NULL,0,0,2 ...

  7. Chapter 1 First Sight——21

    They were sitting in the corner of the cafeteria, as far away from where I sat as possible in the lo ...

  8. 仿照微信的界面,即ViewPager+Fragment的结合使用

    主布局文件: android:drawableTop="@drawable/weixin_bg"用的是状态选择器,所以要写4个状态选择器,图片的 <RelativeLayou ...

  9. Javascript面向对象编程(二):构造函数的继承

    这个系列的第一部分,主要介绍了如何"封装"数据和方法,以及如何从原型对象生成实例. 今天要介绍的是,对象之间的"继承"的五种方法. 比如,现在有一个" ...

  10. C# 经典入门12章-使用泛型-1

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAA8sAAAK5CAIAAAAHDiuGAAAgAElEQVR4nOyd9V9Uzfv/v3/J0t0N0p