普通网友 2016-04-26 06:03 采纳率: 33.3%
浏览 1638
已结题

自定义UITableVIewCell为啥textColor颜色设置不生效了

//
// HQTableViewCell.m
// TableViewTest
//
// Created by hq on 16/4/26.
// Copyright © 2016年 hanqing. All rights reserved.
//

#import "HQTableViewCell.h"

@interface HQTableViewCell()

@property (weak, nonatomic) IBOutlet UILabel *label;

@end

@implementation HQTableViewCell

+(instancetype) tableViewCell:(UITableView *)tableView{

NSString *ID=@"cell";

HQTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:ID];


if (cell==nil) {

    [tableView registerNib:[UINib nibWithNibName:@"cell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:ID];

    cell=[tableView dequeueReusableCellWithIdentifier:ID];

    **cell.textLabel.textColor=[UIColor redColor];

            cell.textLabel.highlightedTextColor=[UIColor grayColor];**

}

return cell;

}

-(void)setStr:(NSString *)str{

_str=str;

self.label.text=str;

}

  • (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state

}

@end

  • 写回答

7条回答

  • 朕就是这么帅 2016-04-26 06:41
    关注

    cell.textLabel.textColor=[UIColor redColor];
    cell.textLabel.highlightedTextColor=[UIColor grayColor];中的textLabel 不是你定义的属性值的label,textLabel cell 默认的一个label

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?