NSMutableAttributedString's attribute NSStrikethroughStyleAttributeName doesn't work correctly in iOS8

后端 未结 6 1201
猫巷女王i
猫巷女王i 2020-12-31 21:36

I have a mutable attributed string without NSStrikethroughStyleAttributeName attribute like this:

NSMutableAttributedString *str1 = [[NSMutableAttributedStri         


        
6条回答
  •  滥情空心
    2020-12-31 21:58

    When you are not starting the index from 0, try this:

    NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:@"Hello"];
    [attributedStr addAttributes:@{NSStrikethroughStyleAttributeName : @(NSUnderlineStyleSingle)} range:NSMakeRange(1, str.length)];
    [attributedStr addAttributes:@{NSStrikethroughStyleAttributeName : @(NSUnderlineStyleNone)} range:NSMakeRange(0, 1)];
    

提交回复
热议问题