首页 > 移动平台 > 详细

iOS开篇——UI之UITableView 自定义Cell

时间:2015-12-08 00:31:28      阅读:272      评论:0      收藏:0      [点我收藏+]

创建一个继承于UITableViewCell的类

重写父类方法

1 //先重写父类方法
2 - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
3     if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
4         [self customCell];
5     }
6     return self;
7 }

再实现customCell方法

- (void)customCell{
//    _label = [[UILabel alloc]initWithFrame:CGRectMake(50, 5, 25, 20)];
//    _label.text = @"全天";
//    _label.textColor = [UIColor blackColor];
//    _label.adjustsFontSizeToFitWidth = YES;
//    //
//    
//    _view = [[UIView alloc]initWithFrame:CGRectMake(80, 1, 1, 42)];
//    _view.backgroundColor = [UIColor darkGrayColor];
//    _view.alpha = 0.3;
//    [self.contentView addSubview:_view];
//    [self.contentView addSubview:_label];
//    
//    UIView * view = [[UIView alloc]initWithFrame:CGRectMake(85, 7.5, 10, 10)];
//    view.backgroundColor = [UIColor redColor];
//    view.alpha = 0.7;
//    [self.contentView addSubview:view];
//    
//    _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(100, 5, 100, 15)];
//    _titleLabel.font = [UIFont boldSystemFontOfSize:14];
//    _titleLabel.textColor = [UIColor darkTextColor];
//    
//    [self.contentView addSubview:_titleLabel];
    
    
    
    _label = [[UILabel alloc]initWithFrame:CGRectMake(30, 10, 50, 24)];
    _label.textColor = [UIColor blackColor];
    
    [self.contentView addSubview:_label];
    
//    _theSwitch = [[UISwitch alloc]initWithFrame:CGRectMake(self.contentView.frame.size.width-30, 7, 30, 10)];
//    
//    [self.contentView addSubview:_theSwitch];
    
    
    
}

 

iOS开篇——UI之UITableView 自定义Cell

原文:http://www.cnblogs.com/gwkiOS/p/5027910.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!