BaseCell

2017-10-23  本文已影响0人  朝前走不停歇

//
// BaseCell.m
// HomeDecorate
//
// Created by mac on 16/8/22.
// Copyright © 2016年 eluotuo. All rights reserved.
//

import <UIKit/UIKit.h>

@interface BaseCell : UITableViewCell

/**
快速创建cell

@param tableView 关联表格
@return cell
/
+(instancetype)cellForTableView:(UITableView
)tableView;

/**
快速创建cell

@param tableView 关联表格
@param identifier 标示位
@param style 展示类型
@return cell
/
+(instancetype)cellForTableView:(UITableView
)tableView Identifier:(NSString*)identifier style:(UITableViewCellStyle)style;

/**
设置视图
*/
-(void)hd_setupSubviews NS_REQUIRES_SUPER;

@end

//
// BaseCell.m
// HomeDecorate
//
// Created by mac on 16/8/22.
// Copyright © 2016年 eluotuo. All rights reserved.
//

import "BaseCell.h"

@implementation BaseCell

+(instancetype)cellForTableView:(UITableView)tableView{
return [self cellForTableView:tableView Identifier:[self cellReuseIdentifier] style:UITableViewCellStyleDefault];
}
+(instancetype)cellForTableView:(UITableView
)tableView Identifier:(NSString*)identifier style:(UITableViewCellStyle)style {

BaseCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
 
if (!cell) {
    
    cell = [[self alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
    
    cell.backgroundColor = [UIColor whiteColor];
    
    cell.clipsToBounds = YES;
    
    [cell.imageView sizeToFit];
     
}
return cell;

}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self hd_setupSubviews];
}
return self;
}

-(void)hd_setupSubviews{}

@end

上一篇 下一篇

猜你喜欢

热点阅读