删除文本的最佳方式

Best way to strike out a text

提问人:gabac 提问时间:10/26/2010 最后编辑:rptwsthigabac 更新时间:7/11/2013 访问量:8430

问:

到目前为止,iPhone上删除文本的最佳解决方案是什么?

我听说过多种解决方案:

  • 有three20的东西
  • 图像作为子视图
  • UIWebView还有一些带有 的东西,但我没有找到一个工作的例子。NSAttributedString
iPhone NSS字符串 UILobe

评论


答:

-1赞 Guntis Treulands 9/4/2012 #1

你可以试试我的 UILabel 子类解决方案,它支持:

具有各种标签边界的多行文本(文本可以位于标签框的中间,也可以是准确的大小)

  • 下划线
  • 三振出局
  • 下划线/删除线偏移量
  • 文本对齐方式
  • 不同的字体大小

https://github.com/GuntisTreulands/UnderLineLabel

10赞 HDdeveloper 7/11/2013 #2

在iOS 6中,我们可以使用“NSMutableAttributedString”来使用更多不同的样式。

    NSString* cutText = @"This Line is strike out.";

    NSMutableAttributedString *titleString = [[NSMutableAttributedString alloc] initWithString:cutText];

    // making text property to strike text- NSStrikethroughStyleAttributeName
    [titleString addAttribute:NSStrikethroughStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [titleString length])];

    // using text on label
    [myTextLabel  setAttributedText:titleString];