删除文本的最佳方法

发布于 2024-09-29 04:08:34 字数 200 浏览 0 评论 0原文

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

我听说过多种解决方案:

  • 以 Three20
  • Image 作为子视图
  • UIWebView 还有一些带有 NSAttributedString 的东西,但我没有找到有效的示例。

What is the best solution so far for a strike out text on the iPhone?

I heard of multiple solutions:

  • Something with three20
  • Image as a subview
  • UIWebView
    And something with a NSAttributedString, but I don't find a working example for that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

吐个泡泡 2024-10-06 04:08:34

在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];

In iOS 6 we can use "NSMutableAttributedString" for use more different styles.

    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];
昔梦 2024-10-06 04:08:34

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

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

  • 下划线
  • 删除线
  • 下划线/删除线偏移
  • 文本对齐
  • 不同的字体大小

https://github.com/GuntisTreulands/UnderLineLabel

You can try my solution of UILabel subclass, which supports:

multiline text with various label bounds (text can be in the middle of label frame, or accurate size)

  • underline
  • strikeout
  • underline/strikeout line offset
  • text alignment
  • different font sizes

https://github.com/GuntisTreulands/UnderLineLabel

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文