0

我在使用TTTAttributedLabel的时候有个问题。我正在尝试让一个Label首先显示最多8行,如果字母超过8行范围,最后这里是一个标题为“更多”的通知按钮,不同颜色并带有下划线. 我的问题是当我使用“更多”时,外观与我预期的一样。但是,当我使用“展开”(将单词“more”翻译成中文)时,奇怪的是我设置的下划线单词没有显示下划线。我尝试修改行高和偏移量,但下划线结果没有任何改变。代码:`

    NSMutableAttributedString *moreButtonAttributedString = [[NSMutableAttributedString alloc] initWithString:@"...展开"];
    
    [buttonAttributedString addAttribute:NSFontAttributeName value:self.Font range:totalRange];
    [buttonAttributedString addAttribute:NSForegroundColorAttributeName value:self.labelTextColor range:totalRange];
    [buttonAttributedString addAttribute:NSForegroundColorAttributeName value:moreButtonColor range:textRange];
    [moreButtonAttributedString addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:textRange];
    [moreButtonAttributedString addAttribute:NSUnderlineColorAttributeName value:moreButtonColor range:textRange];
    [self.Label setAttributedTruncationToken:moreButtonAttributedString];

`

使用“展开” 时使用更多

4

0 回答 0