zoukankan      html  css  js  c++  java
  • iOS开篇——UI之UITableView 自定义Cell

    创建一个继承于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];
        
        
        
    }
  • 相关阅读:
    MyBatis学习记录02篇
    Mybatis学习记录01篇
    项目路径问题
    项目01-JavaWeb网上书城01之工具类
    面试篇01
    创建多线程的方式
    关于web.xml
    快捷键----快速生成未实现的方法
    自动化学习-Day03
    自动化学习-Day02
  • 原文地址:https://www.cnblogs.com/gwkiOS/p/5027910.html
Copyright © 2011-2022 走看看