1111111

//

// + (instancetype)cellWithTableView:(UITableView *)tableView

//{

//    static NSString *identifier = @"status";

//        // 1.缓存中取

//    WaitFollowCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];

//    // 2.创建

//        if (cell == nil) {

//                 cell = [[WaitFollowCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];

//            }

//        return cell;

//     }

 

- (void)awakeFromNib {

    [super awakeFromNib];

    // Initialization code

  

}

 

 

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];

    if (self) {

        

//            self.nameLabel=[[UILabel alloc]initWithFrame:CGRectMake(10,15,80,24)];

//            self.nameLabel.textAlignment=NSTextAlignmentLeft;

//            self.nameLabel.font=[UIFont systemFontOfSize:18];

//            [self.contentView addSubview:self.nameLabel];

//            

//            _headImageview = [[UIImageView alloc]initWithFrame:CGRectMake(14, 7, 54, 54)];

//            _headImageview.backgroundColor = [UIColor redColor];

//            _headImageview.layer.masksToBounds = YES;

//            _headImageview.layer.cornerRadius = 27;

//            [self.contentView addSubview:_headImageview];

//        

//            _nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(_headImageview.frame)+10, 26, SCREEN_WIDTH-165, 20)];

//            _nameLabel.backgroundColor = [UIColor purpleColor];

//            _nameLabel.font = [UIFont systemFontOfSize:16.0];

//            [self.contentView addSubview:_nameLabel];

//        

//            _revokeLabel = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-84, 12, 70, 20)];

//            _revokeLabel.centerY = _nameLabel.centerY;

//            _revokeLabel.backgroundColor = [UIColor lightGrayColor];

//            _revokeLabel.font = [UIFont systemFontOfSize:14.0];

//            [self.contentView addSubview:_revokeLabel];

        

            

        

    }

    

    return self;

}

 

 

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {

    [super setSelected:selected animated:animated];

    //???2016

//    self.backgroundColor = [UIColor yellowColor];

//    _headImageview = [[UIImageView alloc]initWithFrame:CGRectMake(14, 7, 54, 54)];

//    _headImageview.backgroundColor = [UIColor redColor];

//    _headImageview.layer.masksToBounds = YES;

//    _headImageview.layer.cornerRadius = 27;

//    [self.contentView addSubview:_headImageview];

//    

//    _nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(_headImageview.frame)+10, 26, SCREEN_WIDTH-165, 20)];

//    _nameLabel.backgroundColor = [UIColor purpleColor];

//    _nameLabel.font = [UIFont systemFontOfSize:16.0];

//    [self.contentView addSubview:_nameLabel];

//    

//    _revokeLabel = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-84, 12, 70, 20)];

//    _revokeLabel.centerY = _nameLabel.centerY;

//    _revokeLabel.backgroundColor = [UIColor lightGrayColor];

//    _revokeLabel.font = [UIFont systemFontOfSize:14.0];

//    [self.contentView addSubview:_revokeLabel];

    

}

 

 

//- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier

//{

//    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];

//    if (self) {

//        self.backgroundColor = [UIColor yellowColor];

//        _headImageview = [[UIImageView alloc]init];

//        _headImageview.backgroundColor = [UIColor redColor];

//        [self.contentView addSubview:_headImageview];

//        

//        _nameLabel = [[UILabel alloc]init];

//        _nameLabel.backgroundColor = [UIColor purpleColor];

//        [self.contentView addSubview:_nameLabel];

//        

//        _revokeLabel = [[UILabel alloc]init];

//        _revokeLabel.backgroundColor = [UIColor lightGrayColor];

//        [self.contentView addSubview:_revokeLabel];

//        

//    }

//    return self;

//}

//

////当父容器的frame发生改变时,会调用该方法,常常用来设置子控件的fram

//-(void)layoutSubviews{

//    

//    //这里一定要先调用父类的方法,否则你会很痛苦T_T

//    [super layoutSubviews];

//    

//    _headImageview.frame = CGRectMake(14, 7, 54, 54);

//    _headImageview.layer.masksToBounds = YES;

//    _headImageview.layer.cornerRadius = 27;

//    

//    _nameLabel.frame = CGRectMake(CGRectGetMaxX(_headImageview.frame)+10, 26, SCREEN_WIDTH-165, 20);

//    _nameLabel.font = [UIFont systemFontOfSize:16.0];

//    

//    _revokeLabel.frame = CGRectMake(SCREEN_WIDTH-84, 12, 70, 20);

//    _revokeLabel.centerY = _nameLabel.centerY;

//    _revokeLabel.font = [UIFont systemFontOfSize:14.0];

//

//}

 

 

- (id)initWithFrame:(CGRect)frame

{

    self = [super initWithFrame:frame];

    if (self) {

        self.backgroundColor = RGB(239, 239, 239);//[UIColor blueColor];

        _headImageview = [[UIImageView alloc]initWithFrame:CGRectMake(14, 7, 54, 54)];

        _headImageview.backgroundColor = [UIColor redColor];

        _headImageview.layer.masksToBounds = YES;

        _headImageview.layer.cornerRadius = 27;

        [self.contentView addSubview:_headImageview];

        

        _nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(_headImageview.frame)+10, 26, SCREEN_WIDTH-165, 20)];

        _nameLabel.backgroundColor = [UIColor purpleColor];

        _nameLabel.font = [UIFont systemFontOfSize:16.0];

        [self.contentView addSubview:_nameLabel];

        

        _revokeLabel = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-84, 12, 70, 20)];

        _revokeLabel.centerY = _nameLabel.centerY;

        _revokeLabel.backgroundColor = [UIColor lightGrayColor];

        _revokeLabel.font = [UIFont systemFontOfSize:14.0];

        [self.contentView addSubview:_revokeLabel];

    }

    return self;

}

原文地址:https://www.cnblogs.com/gzz2016/p/6070328.html