UILabel文本truncatingtail圆点颜色

时间:2014-04-03 05:40:24

标签: ios objective-c uilabel

我有一个UILabeltextColor设置为 white 。但是,标签末尾的截断仍然是黑色

我没有声望发布图片here is a link。如果链接不起作用,请提前抱歉。

我使用的是UICollectionView,文字是UILabel,这是我的标签代码:

    UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(8.0f, 4.0f, 135.0f, 36.0f)];
    nameLabel.numberOfLines = 2;
    nameLabel.lineBreakMode = NSLineBreakByTruncatingTail;
    nameLabel.text = _name;
    nameLabel.font = [UIFont fontWithName:@"STHeitiSC-Medium" size:15.0f];
    [nameLabel sizeToFit];
    nameLabel.textColor = [UIColor whiteColor];
    [purpleMask addSubview:nameLabel];

有没有人遇到过这类问题?

2 个答案:

答案 0 :(得分:2)

添加如下内容:

NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"Presenting the great..."];
[string addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20.0] range:NSMakeRange(24, 11)];

        nameLabel.attributedText =  string;

答案 1 :(得分:1)

如果您使用

,它的工作原理
   UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(80.0f, 140.0f, 135.0f, 36.0f)];
nameLabel.numberOfLines = 2;
//nameLabel.lineBreakMode = NSLineBreakByTruncatingTail;
nameLabel.lineBreakMode = NSLineBreakByWordWrapping;
nameLabel.text = @"xiusd fdhsf kdsfhkdhskf ih khkh khk fdg dfgdf dfgdfgdfgdfgdfgdfgdfgdfgdfsgdf fdg dfs gdf df fg gdfdfs gdgdfg d gdfg ds  hk hkh kh khk hk hk h";
nameLabel.font = [UIFont fontWithName:@"STHeitiSC-Medium" size:15.0f];
[nameLabel sizeToFit];
[nameLabel setTextColor:[UIColor whiteColor]];

nameLabel.backgroundColor = [UIColor yellowColor];
//nameLabel.textColor = [UIColor whiteColor];
[self.view addSubview:nameLabel];