文字上添加删除线

    NSString * str = @"ABCDEFG HIJKLMN";

    UILabel * aLab = [[UILabel alloc]initWithFrame:CGRectMake(10, 100, 300, 300)];

    aLab.text = str;

    NSMutableAttributedString * testAttriString = [[NSMutableAttributedString alloc] initWithString:str];

   [testAttriString addAttribute:NSStrikethroughStyleAttributeName value:[NSNumber numberWithInt:NSUnderlineStyleSingle] range:NSMakeRange(0, testAttriString.length)];

    aLab.attributedText = testAttriString;

    [self.view addSubview:aLab];

发帖时间: iOS