uitableview – UILabel和UILabel在iOS 7中的省略号颜色变化

我看到包含带省略号的UILabel的UITableViewCells发生了一些非常奇怪的事情(这个项目仅限iOS 7).我在tableView首次加载时看到省略号.然后,如果我按下一个单元格,文本省略号的颜色就像我在setHighlighted函数中所要求的那样改变.但是当我发布它时(当我转到详细信息viewController并回到第一个带有表视图的viewController,或者只是按下然后滚动以松开突出显示)时,省略号消失了.

事实上,我发现它仍然存在,只是它在白色背景上是白色的(文本高亮的颜色,见底部的代码).为了更好地理解,这里是屏幕显示我刚才描述的内容:

Before clicking :

The cell is highlighted while we click :

After clicking,moving to the next viewController and pressing back :

请注意,如果我通过滚动单击松开突出显示,则只有突出显示的单元格会丢失省略号.此外,当滚动tableView时,一切都很好,直到我到达它的底部,并加载列表的下一个元素 – 然后所有省略号保持白色(以及突出显示的字体,这是粗体).这让我相信这是由重新加载单元格数据时所做的事情引起的.

这是setHighlighted的代码:

-(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
    NSUInteger fontSize = _titleLabel.font.pointSize;

    [UIView animateWithDuration:(highlighted ? .2 : .5)
                          delay:0
                        options:UIViewAnimationOptionBeginFromCurrentState
                     animations:^{
                         _background.backgroundColor = (highlighted ? [UIColor blueND] : [UIColor whiteColor]);
                         _hourLabel.textColor = (highlighted ? [UIColor whiteColor] : [UIColor blackColor]);
                         _titleLabel.textColor = (highlighted ? [UIColor whiteColor] : [UIColor blackColor]);
                         _titleLabel.font = (highlighted ? [UIFont boldSystemFontOfSize:fontSize] : [UIFont systemFontOfSize:fontSize]);
                         _consoleLabel.textColor = (highlighted ? [UIColor blueND] : [UIColor whiteColor]);
                         _consoleLabel.backgroundColor = (highlighted ? [UIColor whiteColor] : [UIColor blueND]);
                     }
                     completion:nil];
}

有没有人知道这里发生了什么?

提前谢谢你的帮助 !

更新:根据Leo Natan的评论,这里是突出显示的单元格的po _titleLabel.attributedString的结果,一旦突出显示,然后发布:

(lldb) po _titleLabel.attributedText
Mario Golf : World Tour,le Lagon Cheep Cheep en vidéo{
    NSColor = "UIDeviceWhiteColorSpace 0 1";
    NSFont = "<UICTFont: 0x1669a990> font-family: \".HelveticaNeueInterface-Regular\"; font-weight: normal; font-style: normal; font-size: 14.00pt";
    NSParagraphStyle = "Alignment 0,LineSpacing 0,ParagraphSpacing 0,ParagraphSpacingBefore 0,HeadIndent 0,TailIndent 0,FirstLineHeadIndent 0,LineHeight 0/0,LineHeightMultiple 0,LineBreakMode 4,Tabs (\n    28L,\n    56L,\n    84L,\n    112L,\n    140L,\n    168L,\n    196L,\n    224L,\n    252L,\n    280L,\n    308L,\n    336L\n),DefaultTabInterval 0,Blocks (null),Lists (null),BaseWritingDirection -1,HyphenationFactor 0,TighteningFactor 0,HeaderLevel 0";
    NSShadow = "NSShadow {0,-1} color = {(null)}";
}

解决方法

这可能是系统的一个错误.确保打开错误报告.

正如评论中所设计的那样,您可以使用标签的highlightTextColor和单元格的selectedBackgroundView来实现您尝试的方式,而不是手动设置颜色.

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...