//自定义cell的方法
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
MyVoucherCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (cell == nil) {
cell = [[[NSBundle mainBundle]loadNibNamed:NSStringFromClass([MyVoucherCell class]) owner:self options:nil] lastObject];
cell.backgroundColor = [UIColor clearColor];
UIImageView *imageView = [self pastImageView]; //调用三次
[cell.backImageView addSubview:imageView];
[imageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(cell.backImageView.mas_top).offset(18);
make.right.mas_equalTo(cell.backImageView.mas_right).offset(-75);
make.bottom.mas_equalTo(cell.backImageView.mas_bottom).offset(-17.5);
}];
cell.storeLabel.textColor = [UIColor colorWithHexString:@"9c9c9c"];
cell.limitLabel.textColor = [UIColor colorWithHexString:@"9c9c9c"];
cell.enableLabel.textColor = [UIColor colorWithHexString:@"9c9c9c"];
cell.unitLabel.textColor = [UIColor colorWithHexString:@"9c9c9c"];
cell.priceLabel.textColor = [UIColor colorWithHexString:@"9c9c9c"];
cell.fullLabel.textColor = [UIColor colorWithHexString:@"9c9c9c"];
cell.selectionStyle = UITableViewCellSelectionStyleNone; //去掉点击效果
}
return cell;
}
-(UIImageView *)pastImageView{
_pastImageView = [[UIImageView alloc]init];
_pastImageView.image = [UIImage imageNamed:@"已过期"];
return _pastImageView;
不能用 if( nil == _pastImageView); 防止重复创建一个对象,比拟单例
}
网友评论