Ios 自定义单元格-更改自定义单元格中背景和按钮的颜色
我在iterfacebuilder中创建了一个自定义单元格,并将其连接到.h文件 然后在我的CustomCell.m文件中Ios 自定义单元格-更改自定义单元格中背景和按钮的颜色,ios,objective-c,uitableview,custom-cell,Ios,Objective C,Uitableview,Custom Cell,我在iterfacebuilder中创建了一个自定义单元格,并将其连接到.h文件 然后在我的CustomCell.m文件中 @implementation TwoMealsTableViewCell @synthesize dayLabel, firstMealBtn, secondMealBtn, indexPath; - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdent
@implementation TwoMealsTableViewCell
@synthesize dayLabel, firstMealBtn, secondMealBtn, indexPath;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
dayLabel.textColor = [UIColor orangeColor];
if (self) {
dayLabel.textColor = [UIColor orangeColor];
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
我在tableview中设置了所有单元格,我看到了按钮和标签,但我没有看到颜色的变化
这是为什么
提前谢谢你的帮助 这将更改单元格颜色
dayLabel.textColor = [UIColor orangeColor];
您的xib/故事板中的标签是否连接到相应的插座?是否调用了
initWithStyle:reuseIdentifier:
方法?可能不适用于通过IB创建的自定义单元格。@asifas如果是,则在故事板中创建的单元格将调用标签connectedinitWithCoder,但现在获取输出还为时过早。使用awakeFromNib,插座是按调用的时间设置的。然后您应该在表视图控制器中实现tableView:heightForRowAtIndexPath:。