zoukankan      html  css  js  c++  java
  • 自定义控件

    //
    //  MyTableViewCell.m
    //  MyTableCell
    //
    //  Created by apple on 14-8-6.
    //  Copyright (c) 2014年 apple. All rights reserved.
    //
    
    #import "MyTableViewCell.h"
    
    @implementation MyTableViewCell
    
    - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
    {
        self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
        if (self) {
            _label=[[UILabel alloc]initWithFrame:CGRectMake(230, 0, 110, 30)];
    //        _label.backgroundColor=[UIColor redColor];
            _label.font=[UIFont systemFontOfSize:13];
            [self.contentView addSubview:_label];
    //
    //        self.textLabel.backgroundColor = [UIColor clearColor];
        }
        return self;
    }
    
    - (void)awakeFromNib
    {
        // Initialization code
    }
    
    - (void)setSelected:(BOOL)selected animated:(BOOL)animated
    {
        [super setSelected:selected animated:animated];
    
        // Configure the view for the selected state
    }
    
    - (void)layoutSubviews
    {
        [super layoutSubviews];
        
    //        self.textLabel.frame = CGRectMake(250, 0, 100, 40);
    }
    
    @end
    
    
    
    
    //
    //  ViewController.m
    //  MyTableCell
    //
    //  Created by apple on 14-8-6.
    //  Copyright (c) 2014年 apple. All rights reserved.
    //
    
    #import "ViewController.h"
    #import "MyTableViewCell.h"
    @interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
    {
        UITableView *_tableView;
    }
    
    @end
    
    @implementation ViewController
                
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        _tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 20, 320, 400) style:UITableViewStylePlain];
        _tableView.delegate=self;
        _tableView.dataSource=self;
        [self.view addSubview:_tableView];
        
        [_tableView registerClass:[MyTableViewCell class] forCellReuseIdentifier:@"cell"];
    }
    
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        return 30;
    }
    
    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        MyTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    //    if (cell==nil)
    //    {
    //        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    //    }
    //
        cell.label.text=@"liSi";
    
        cell.textLabel.text=@"2222";
        return cell;
        
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    @end
  • 相关阅读:
    Security and Cryptography in Python
    Security and Cryptography in Python
    Security and Cryptography in Python
    Security and Cryptography in Python
    Security and Cryptography in Python
    Security and Cryptography in Python
    Security and Cryptography in Python
    微信小程序TodoList
    C语言88案例-找出数列中的最大值和最小值
    C语言88案例-使用指针的指针输出字符串
  • 原文地址:https://www.cnblogs.com/lidongq/p/3895792.html
Copyright © 2011-2022 走看看