问题标签 [tttattributedlabel]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
4100 浏览

ios - iPhone - 从 UILabel 中的链接中删除下划线

我正在使用 TTTAttributedLabel ( https://github.com/twotoasters/TTTAttributedLabel )。在这里,我正确地获得了带有一些可点击文本的标签。

在此处输入图像描述

我需要像上图中的用户名一样显示我的文本(即没有下划线)。我该怎么做?

0 投票
1 回答
2469 浏览

ios - TTTAttributedLabel "Read More >" 可能带有多个属性的尾部截断?

TTTAttributedLabeltruncationTokenString通过和支持自定义截断字符串truncationTokenStringAttributes

但是,我想更进一步,在截断字符串上设置几个字符串属性,包括不同的字体和颜色。这就是我想要实现的目标:

截断的字符串

最后的箭头可以使用字体图标来实现,所以我想到了以下字符串:

@"… Read More >"

'HORIZONTAL ELLIPSIS' (U+2026)+ Read More+ > character from a font

不幸的是TTTAttributedLabel不允许我设置各种属性的范围。

有没有人对此有一个好的解决方案,或者必须手动完成并基本上计算字符串,因为它可以绘制在包括@"… Read More >"字符串在内的两条线上。

谢谢!

0 投票
1 回答
2111 浏览

ios - 使 UILabel 文本可点击

我想让一些特定的文本可以点击,UILabel例如:@"Lorem Ipsum is simply dummy text of the printing bla bla"

在这个字符串"Ipsum,dummy,printing"中应该是可点击的,并且它的颜色也应该改变。我用(自定义类)试过这个,TTTAttributedLabel但它只是改变颜色。

请给我任何有用的建议。

0 投票
1 回答
1469 浏览

tttattributedlabel - TTTAttributedLabel : 检测链接问题。

我在使用 TTTAttributedLabel 时遇到了一些问题。有时,给定的 URL 不会被着色为链接,也不会对触摸做出反应。但是,这可以通过向下和向上滚动来解决,因此可以通过重新绘制 Cell 视图来解决。我查看了项目 github 中的问题,但似乎相关的问题已经关闭。

0 投票
0 回答
272 浏览

ios - TTTAttributedLabel 的 touchesBegan 没有被调用

每个人。

我一直在我的 iOS 应用程序上使用 TTTAttributedLabel,我使用 addLinkToURL:withRange: 方法。但是,有时 TTTAttributedLabel 的 touchesBegan 不会被调用。

这是我的代码。这段代码在外面工作得很好。但是,有时不会调用 TTTAttributedLabel 的委托方法。所以,我检查了失败的原因,我发现 TTTAttributedLabel 的 touchesBegan 有时没有被调用。当标签的上部被点击时,touchesBegan 被调用。但是,当标签的底部被点击时,它不会被调用。

我不知道为什么...

请帮我...

这是 cellForRowAtIndexPath: 方法。messageLabel 是 TTTAttributedLabel 的一个实例。

heightForRowAtIndexPath:

谢谢。

0 投票
2 回答
4683 浏览

ios - Specify multiple/conditional link colors in TTTAttributedLabel

I've added a link detector to TTTAttributedLabel that identifies @mentions and #hashtags and creates a link at that position in my TTTAttributedLabel instance:

I've also discovered that I can do this to easily change the link colors and attributes:

But this changes the colors for every link attribute - including web links, hashtags, and mentions. Is there a way to create different link colors using a regular expression or range? Say if I wanted @mentions to be gray, @hashtags to be red, and web links to be blue?

0 投票
6 回答
4735 浏览

ios - 在 TTTAttributedLabel 的超级视图上有一个 UITapGestureRecognizer 时,点击 URL 不起作用

有容器视图和一个UITapGestureRecognizer就可以了。而且它还有一个子视图是哪一种TTTAttributedLabel

当我从容器视图中删除手势识别器时,委托方法TTTAttributedLabelDelegate

当我在容器视图上添加手势识别器时。只有它的动作方法被调用。的委托方法TTTAttributedLabelDelegate不会被调用。

现在我需要在点击 中的链接时调用委托方法TTTAttributedLabel,并在点击容器视图的其他区域时调用操作方法。

谢谢。

0 投票
6 回答
14168 浏览

ios - UILabel:自定义下划线颜色?

我需要 a 的文本为UILabel黑色,但文本下方有浅灰色下划线。这可以用NSAttributedStringorTTTAttributedLabel吗?或者是否需要使用 Core Graphics 进行自定义绘图?

澄清:我需要不同颜色下划线的特定颜色文本。示例:红色下划线上的蓝色文本。

0 投票
2 回答
1752 浏览

ios - 如何使 TTTAttributedLabel 的 truncationTokenString 成为链接?

我有一个用于 iOS 6.1的带有 TTTAttributedLabel ( https://github.com/mattt/TTTAttributedLabel ) 的自定义 UITableViewCell。我使用 TTTAttributedLabel 的 truncationtokenstring 属性来格式化结尾(默认为省略号 ...),当文本太长并被截断为:“...阅读更多 >”。

我可以通过改变它的前景色等来格式化这个截断标记字符串,就像在这篇文章中一样: TTTAttributedLabel "Read More >" tail truncation with several attributes possible?

但是如何使 truncationtokenstring 成为链接,以便当用户单击“...阅读更多 >”时,我可以调用委托并显示更多信息?

0 投票
2 回答
2203 浏览

ios - 如何将自定义字体应用于 TTTAttributedLabel

我在我的项目中使用TTTAttributedLabel。我正在尝试为该标签应用自定义字体。

我使用下面的代码来设置字体:

但在我的应用程序中,字体没有被应用。我需要黑色的“欢迎”文本,文本的其余部分为红色。但是对于我的标签,我需要应用我的自定义字体。