12306

作者: Wang99 | 来源:发表于2018-04-07 14:45 被阅读0次

    ViewController.m

    #import "ViewController.h"
    #import "cheViewController.h"
    #import "shangViewController.h"
    #import "dingViewController.h"
    #import "woViewController.h"
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        cheViewController *che = [[cheViewController alloc]init];
        che.title = @"车票预订";
        UINavigationController *nav1 = [[UINavigationController alloc]initWithRootViewController:che];
        nav1.tabBarItem.title = @"车票预订";
        [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, [UIFont fontWithName:@"Helvetica" size:12.0f],NSFontAttributeName,nil] forState:UIControlStateSelected];
        [[UITabBar appearance] setBarTintColor:[UIColor blackColor]];
        
        shangViewController *shang = [[shangViewController alloc]init];
        shang.title = @"商旅查询";
        UINavigationController *nav2 = [[UINavigationController alloc]initWithRootViewController:shang];
        nav2.tabBarItem.title = @"商旅服务";
        
        dingViewController *ding = [[dingViewController alloc]init];
        ding.title = @"订单查询";
        UINavigationController *nav3 = [[UINavigationController alloc]initWithRootViewController:ding];
        nav3.tabBarItem.title = @"订单查询";
        
        woViewController *wo = [[woViewController alloc]init];
        wo.title = @"我的12306";
        UINavigationController *nav4 = [[UINavigationController alloc]initWithRootViewController:wo];
        nav4.tabBarItem.title = @"我的12306";
        
        self.viewControllers = @[nav1,nav2,nav3,nav4];
        
    }
    
    
    @end
    

    cheViewController.m

    #import "cheViewController.h"
    #import "yiTableViewCell.h"
    #import "erTableViewCell.h"
    #import "sanTableViewCell.h"
    #import "siTableViewCell.h"
    #import "chaxunViewController.h"
    
    
    static NSString *celli = @"yide";
    static NSString *cellID = @"adad";
    static NSString *cellIDs = @"adads";
    static NSString *cellIDse = @"adadse";
    
    @interface cheViewController ()<UITableViewDelegate,UITableViewDataSource,SGPageTitleViewDelegate>
    
    {
        UITableView *table;
    }
    
    @end
    
    @implementation cheViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0/250.0 green:137/250.0 blue:211/250.0 alpha:1];
        [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
        
        table = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
        table.delegate = self;
        table.dataSource = self;
        
        [table registerClass:[yiTableViewCell class] forCellReuseIdentifier:celli];
        [table registerClass:[erTableViewCell class] forCellReuseIdentifier:cellID];
        [table registerClass:[sanTableViewCell class] forCellReuseIdentifier:cellIDs];
        [table registerClass:[siTableViewCell class] forCellReuseIdentifier:cellIDse];
        [self.view addSubview:table];
        
        
        
    }
    
    -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
        return 6;
    }
    
    -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        if (section == 5) {
            return 5;
        }
        return 1;
    }
    -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        if (indexPath.section == 0) {
            return 100;
        }else if (indexPath.section == 2) {
            return 230;
        }else if (indexPath.section == 3) {
            return 220;
        }
        return 100;
    }
    
    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        UITableViewCell *cell;
        
        switch (indexPath.section) {
            case 0:
                {
                    yiTableViewCell *cells = [tableView dequeueReusableCellWithIdentifier:celli];
                    if (!cells) {
                        cells = [[yiTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:celli];
                    }
                    
                    return cells;
                }
                break;
                
            case 1:
            {
                erTableViewCell *cellse = [tableView dequeueReusableCellWithIdentifier:cellID];
                if (!cellse) {
                    cellse = [[erTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
                }
    
                return cellse;
            }
                break;
                
            case 2:
            {
                sanTableViewCell *cellses = [tableView dequeueReusableCellWithIdentifier:cellIDs];
                if (!cellses) {
                    cellses = [[sanTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIDs];
                }
                
                return cellses;
            }
                break;
                
            case 3:
            {
                siTableViewCell *cellsesa = [tableView dequeueReusableCellWithIdentifier:cellIDse];
                if (!cellsesa) {
                    cellsesa = [[siTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIDse];
                }
                
                [cellsesa.btn2 addTarget:self action:@selector(clicks) forControlEvents:UIControlEventTouchUpInside];
                
                return cellsesa;
                
            }
                break;
                
            default:
                
                cell = [tableView dequeueReusableCellWithIdentifier:@""];
                if (!cell) {
                    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@""];
                }
                
                
                break;
        }
        return cell;
    }
    
    -(void)clicks
    {
        NSLog(@"查询");
        chaxunViewController *chaxun = [[chaxunViewController alloc]init];
        chaxun.navigationItem.hidesBackButton = YES;
        [self.navigationController pushViewController:chaxun animated:YES];
    }
    
    @end
    

    chaxunViewController.m

    #import "chaxunViewController.h"
    
    #define Screenwidth [UIScreen mainScreen].bounds.size.width
    #define ScreennHeight [UIScreen mainScreen].bounds.size.height
    
    
    @interface chaxunViewController ()<UITableViewDelegate,UITableViewDataSource>
    {
        BOOL close[30];
    }
    
    
    @property (nonatomic,strong)UILabel *checiLab;
    @property (nonatomic,strong)UILabel *kaishiLab;
    @property (nonatomic,strong)UILabel *kaishitimeLab;
    @property (nonatomic,strong)UILabel *photoLab;
    @property (nonatomic,strong)UILabel *jiantouLab;
    @property (nonatomic,strong)UILabel *sumtimeLab;
    @property (nonatomic,strong)UILabel *jieshuLab;
    @property (nonatomic,strong)UILabel *jieshutimeLab;
    @property (nonatomic,strong)UILabel *shangwuLab;
    @property (nonatomic,strong)UILabel *OneLab;
    @property (nonatomic,strong)UILabel *TwoLab;
    
    @property (nonatomic,strong)UIButton *bottomBtn;
    
    
    @property (nonatomic,strong) UITableView *WBTableView;
    @property (nonatomic,strong) NSArray *Close;
    
    @property(nonatomic,strong)UILabel * label1;
    @property(nonatomic,strong)UILabel * label2;
    @property(nonatomic,strong)UILabel * label3;
    
    @end
    
    
    
    @implementation chaxunViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.title = @"北京<>上海";
        self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0/250.0 green:137/250.0 blue:211/250.0 alpha:1];
        [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
        
        UIButton *leftbtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [leftbtn setTitle:@"<" forState:UIControlStateNormal];
        leftbtn.tintColor = [UIColor whiteColor];
        [leftbtn addTarget:self action:@selector(clickleft) forControlEvents:UIControlEventTouchUpInside];
        UIBarButtonItem *leftbtnitem = [[UIBarButtonItem alloc]initWithCustomView:leftbtn];
        self.navigationItem.leftBarButtonItem = leftbtnitem;
        
        
        UIButton *rightbtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [rightbtn setTitle:@"匚" forState:UIControlStateNormal];
        rightbtn.tintColor = [UIColor whiteColor];
        [rightbtn addTarget:self action:@selector(clickright) forControlEvents:UIControlEventTouchUpInside];
        UIBarButtonItem *rightbtnitem = [[UIBarButtonItem alloc]initWithCustomView:rightbtn];
        self.navigationItem.rightBarButtonItem = rightbtnitem;
        
        
        UIView *view = [[UIView alloc]init];
        view.frame = CGRectMake(0, 64, self.view.frame.size.width, 50);
        view.backgroundColor = [UIColor whiteColor];
        [self.view addSubview:view];
        
        _label1 = [[UILabel alloc]init];
        _label1.frame = CGRectMake(0, 0, 100, 50);
        _label1.text = @"      前一天";
        _label1.textColor = [UIColor whiteColor];
        _label1.backgroundColor = [UIColor colorWithRed:90/255.0 green:175/255.0 blue:225/255.0 alpha:1];
        [view addSubview:_label1];
        
        _label2 = [[UILabel alloc]init];
        _label2.frame = CGRectMake(100, 0, 214, 50);
        _label2.text = @"            2017-10-17";
        _label2.font = [UIFont systemFontOfSize:18];
        _label2.textColor = [UIColor whiteColor];
        _label2.backgroundColor = [UIColor colorWithRed:55/255.0 green:145/255.0 blue:205/255.0 alpha:1];
        [view addSubview:_label2];
        
        _label3 = [[UILabel alloc]init];
        _label3.frame = CGRectMake(314, 0, 100, 50);
        _label3.text = @"      后一天";
        _label3.textColor = [UIColor whiteColor];
        _label3.backgroundColor = [UIColor colorWithRed:90/255.0 green:175/255.0 blue:225/255.0 alpha:1];
        [view addSubview:_label3];
        
        //这个的目的是为了使得启动app时,单元格是收缩的
        for (int i=0; i<30; i++) {
            close[i] = YES;
        }
        //创建
        _WBTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 114, Screenwidth, ScreennHeight) style:UITableViewStylePlain];
        _WBTableView.dataSource = self;
        _WBTableView.delegate = self;
        
        [self.view addSubview:self.WBTableView];
        
    }
    
    -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
        return 5;
    }
    
    -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        if (close[section]) {
            return 0;
        }
        return 5;
        
    }
    
    -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        return 50;
    }
    
    -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    {
        return 85;
    }
    
    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        }
        cell.textLabel.text = [NSString stringWithFormat:@"第%ld组 第%ld行",indexPath.section,indexPath.row];
        return cell;
    }
    
    //创建组头视图
    -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
        
        UIControl *view = [[UIControl alloc] initWithFrame:CGRectMake(0, 0, Screenwidth, 85)];
        view.tag = 1000 + section;
        [view addTarget:self action:@selector(sectionClick:) forControlEvents:UIControlEventTouchUpInside];
        
        _checiLab = [[UILabel alloc]initWithFrame:CGRectMake(8, 8, 50, 30)];
        _checiLab.font = [UIFont systemFontOfSize:21];
        _checiLab.textColor = [UIColor blackColor];
        _kaishiLab = [[UILabel alloc]initWithFrame:CGRectMake(65, 8, 70, 25)];
        _kaishiLab.font = [UIFont systemFontOfSize:13];
        _kaishiLab.textColor = [UIColor blackColor];
        _kaishitimeLab = [[UILabel alloc]initWithFrame:CGRectMake(65, 30, 50, 20)];
        _kaishitimeLab.font = [UIFont systemFontOfSize:11];
        _kaishitimeLab.textColor = [UIColor grayColor];
        _photoLab = [[UILabel alloc]initWithFrame:CGRectMake(210, 5, 50, 25)];
        _photoLab.text = @"🇨🇳";
        _jiantouLab = [[UILabel alloc]initWithFrame:CGRectMake(195, 20, 100, 10)];
        _jiantouLab.text = @"------->";
        _sumtimeLab = [[UILabel alloc]initWithFrame:CGRectMake(195, 29, 70, 15)];
        _sumtimeLab.font = [UIFont systemFontOfSize:10];
        _sumtimeLab.textColor = [UIColor grayColor];
        _jieshuLab = [[UILabel alloc]initWithFrame:CGRectMake(280, 8, 100, 25)];
        _jieshuLab.font = [UIFont systemFontOfSize:13];
        _jieshuLab.textColor = [UIColor blackColor];
        _jieshutimeLab = [[UILabel alloc]initWithFrame:CGRectMake(280, 30, 50, 20)];
        _jieshutimeLab.font = [UIFont systemFontOfSize:11];
        _jieshutimeLab.textColor = [UIColor grayColor];
        _shangwuLab = [[UILabel alloc]initWithFrame:CGRectMake(8, 55, 60, 20)];
        _shangwuLab.font = [UIFont systemFontOfSize:11];
        _shangwuLab.textColor = [UIColor blackColor];
        _OneLab = [[UILabel alloc]initWithFrame:CGRectMake(108, 55, 60, 20)];
        _OneLab.font = [UIFont systemFontOfSize:11];
        _OneLab.textColor = [UIColor blackColor];
        _TwoLab = [[UILabel alloc]initWithFrame:CGRectMake(208, 55, 60, 20)];
        _TwoLab.font = [UIFont systemFontOfSize:11];
        _TwoLab.textColor = [UIColor blackColor];
        _bottomBtn = [[UIButton alloc]initWithFrame:CGRectMake(364, 11, 50, 50)];
        [_bottomBtn setImage:[UIImage imageNamed:@"xiangxiajiantou_down_9x9_"] forState:UIControlStateNormal];
        
        _checiLab.text = @"G101";
        _kaishiLab.text = @"🚋北京南";
        _kaishitimeLab.text = @"06:43";
        _sumtimeLab.text = @"05小时56分";
        _jieshuLab.text = @"🏁上海虹桥";
        _jieshutimeLab.text = @"12:39";
        _shangwuLab.text = @"商务: 4张";
        _OneLab.text = @"一等: 有";
        _TwoLab.text = @"二等: 有";
        
        [view addSubview:self.checiLab];
        [view addSubview:self.kaishiLab];
        [view addSubview:self.kaishitimeLab];
        [view addSubview:self.photoLab];
        [view addSubview:self.jiantouLab];
        [view addSubview:self.sumtimeLab];
        [view addSubview:self.jieshuLab];
        [view addSubview:self.jieshutimeLab];
        [view addSubview:self.shangwuLab];
        [view addSubview:self.OneLab];
        [view addSubview:self.TwoLab];
        [view addSubview:self.bottomBtn];
        
        UIView *vv = [[UIView alloc]initWithFrame:CGRectMake(0, 85, Screenwidth, 1)];
        vv.backgroundColor = [UIColor lightGrayColor];
        [view addSubview:vv];
        
        
        
        
        
        return view;
        
    }
    
    /**
     *  cell收缩/展开 刷新
     *
     *  @param view <#view description#>
     */
    -(void)sectionClick:(UIControl *)view{
        
        //获取点击的组
        NSInteger i = view.tag - 1000;
        //取反
        close[i] = !close[i];
        //刷新列表
        NSIndexSet * index = [NSIndexSet indexSetWithIndex:i];
        [_WBTableView reloadSections:index withRowAnimation:UITableViewRowAnimationAutomatic];
    }
    
    
    
    -(void)clickleft
    {
        [self.navigationController popViewControllerAnimated:YES];
    }
    
    -(void)clickright
    {
        NSLog(@"啥");
    }
    
    
    
    @end
    

    shangViewController.m

    #import "shangViewController.h"
    
    @interface shangViewController ()
    
    @end
    
    @implementation shangViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
        self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0/250.0 green:137/250.0 blue:211/250.0 alpha:1];
        [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    /*
    #pragma mark - Navigation
    
    // In a storyboard-based application, you will often want to do a little preparation before navigation
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        // Get the new view controller using [segue destinationViewController].
        // Pass the selected object to the new view controller.
    }
    */
    
    @end
    

    yiTableViewCell.h

    #import <UIKit/UIKit.h>
    
    @interface yiTableViewCell : UITableViewCell
    
    @property(nonatomic,strong)UIButton *btn1;
    @property(nonatomic,strong)UIButton *btn2;
    @property(nonatomic,strong)UIButton *btn3;
    @property(nonatomic,strong)UIButton *btn4;
    @property(nonatomic,strong)UILabel *label1;
    @property(nonatomic,strong)UILabel *label2;
    @property(nonatomic,strong)UILabel *label3;
    @property(nonatomic,strong)UILabel *label4;
    
    @end
    

    yiTableViewCell.m

    #import "yiTableViewCell.h"
    
    @implementation yiTableViewCell
    
    -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
    {
        if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
            _btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
            _btn1.frame = CGRectMake(50, 20, 40, 40);
            _btn1.backgroundColor = [UIColor blueColor];
            [_btn1 addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
            _btn1.layer.masksToBounds = YES;
            _btn1.layer.cornerRadius = 20;
            
            _label1 = [[UILabel alloc]init];
            _label1.frame = CGRectMake(50, 70, 50, 10);
            _label1.font = [UIFont systemFontOfSize:12];
            _label1.text = @"正晚点";
            
            _btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
            _btn2.frame = CGRectMake(140, 20, 40, 40);
            _btn2.backgroundColor = [UIColor greenColor];
            [_btn2 addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
            _btn2.layer.masksToBounds = YES;
            _btn2.layer.cornerRadius = 20;
            
            _label2 = [[UILabel alloc]init];
            _label2.frame = CGRectMake(135, 70, 50, 10);
            _label2.font = [UIFont systemFontOfSize:12];
            _label2.text = @"温馨服务";
            
            _btn3 = [UIButton buttonWithType:UIButtonTypeCustom];
            _btn3.frame = CGRectMake(230, 20, 40, 40);
            _btn3.backgroundColor = [UIColor orangeColor];
            [_btn3 addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
            _btn3.layer.masksToBounds = YES;
            _btn3.layer.cornerRadius = 20;
            
            _label3 = [[UILabel alloc]init];
            _label3.frame = CGRectMake(225, 70, 50, 10);
            _label3.font = [UIFont systemFontOfSize:12];
            _label3.text = @"订餐服务";
            
            _btn4 = [UIButton buttonWithType:UIButtonTypeCustom];
            _btn4.frame = CGRectMake(320, 20, 40, 40);
            _btn4.backgroundColor = [UIColor redColor];
            [_btn4 addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
            _btn4.layer.masksToBounds = YES;
            _btn4.layer.cornerRadius = 20;
            
            _label4 = [[UILabel alloc]init];
            _label4.frame = CGRectMake(325, 70, 50, 10);
            _label4.font = [UIFont systemFontOfSize:12];
            _label4.text = @"约车";
            
            [self.contentView addSubview:self.btn1];
            [self.contentView addSubview:self.btn2];
            [self.contentView addSubview:self.btn3];
            [self.contentView addSubview:self.btn4];
            [self.contentView addSubview:self.label1];
            [self.contentView addSubview:self.label2];
            [self.contentView addSubview:self.label3];
            [self.contentView addSubview:self.label4];
        }
        return self;
    }
    
    -(void)click
    {
        NSLog(@"点我");
    }
    
    @end
    

    erTableViewCell.h

    #import <UIKit/UIKit.h>
    
    @interface erTableViewCell : UITableViewCell
    
    @property(nonatomic,strong)UILabel *label1;
    @property(nonatomic,strong)UILabel *label2;
    @property(nonatomic,strong)UIImageView *image1;
    @end
    

    erTableViewCell.m

    #import "erTableViewCell.h"
    
    @implementation erTableViewCell
    
    -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
    {
        if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
            
            _label1 = [[UILabel alloc]init];
            _label1.text = @"北京";
            _label1.frame = CGRectMake(70, 20, 60, 50);
            _label1.font = [UIFont systemFontOfSize:25];
            
            _label2 = [[UILabel alloc]init];
            _label2.text = @"上海";
            _label2.frame = CGRectMake(290, 20, 60, 50);
            _label2.font = [UIFont systemFontOfSize:25];
            
            _image1 = [[UIImageView alloc]init];
            _image1.frame = CGRectMake(180, 35, 40, 30);
            _image1.image = [UIImage imageNamed:@"切片1副本.png"];
            
            [self.contentView addSubview:self.label1];
            [self.contentView addSubview:self.label2];
            [self.contentView addSubview:self.image1];
        }
        return self;
    }
    
    @end
    

    sanTableViewCell.h

    #import <UIKit/UIKit.h>
    
    @interface sanTableViewCell : UITableViewCell
    
    @property(nonatomic,strong)UILabel *label1;
    @property(nonatomic,strong)UILabel *label2;
    @property(nonatomic,strong)UILabel *label3;
    @property(nonatomic,strong)UILabel *label4;
    @property(nonatomic,strong)UILabel *label5;
    @property(nonatomic,strong)UILabel *label6;
    @property(nonatomic,strong)UILabel *label7;
    
    @end
    

    sanTableViewCell.m

    #import "sanTableViewCell.h"
    
    @implementation sanTableViewCell
    
    -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
    {
        if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
            
            _label1 = [[UILabel alloc]init];
            _label1.frame = CGRectMake(50, 30, 70, 20);
            _label1.text = @"出发日期";
            _label1.textColor = [UIColor grayColor];
            
            _label2 = [[UILabel alloc]init];
            _label2.frame = CGRectMake(50, 100, 70, 20);
            _label2.text = @"出发时间";
            _label2.textColor = [UIColor grayColor];
            
            _label3 = [[UILabel alloc]init];
            _label3.frame = CGRectMake(50, 170, 70, 20);
            _label3.text = @"席       别";
            _label3.textColor = [UIColor grayColor];
            
            _label4 = [[UILabel alloc]init];
            _label4.frame = CGRectMake(150, 30, 100, 20);
            _label4.text = @"2017-10-17";
            
            _label5 = [[UILabel alloc]init];
            _label5.frame = CGRectMake(150, 100, 100, 20);
            _label5.text = @"00.00-24.00";
            
            _label6 = [[UILabel alloc]init];
            _label6.frame = CGRectMake(150, 170, 100, 20);
            _label6.text = @"不限";
            
            _label7 = [[UILabel alloc]init];
            _label7.frame = CGRectMake(320, 30, 70, 20);
            _label7.text = @"学生";
            
            [self addSubview:self.label1];
            [self addSubview:self.label2];
            [self addSubview:self.label3];
            [self addSubview:self.label4];
            [self addSubview:self.label5];
            [self addSubview:self.label6];
            [self addSubview:self.label7];
        }
        return self;
    }
    
    @end
    

    siTableViewCell.h

    #import <UIKit/UIKit.h>
    #import "SGPagingView.h"
    
    @interface siTableViewCell : UITableViewCell<SGPageTitleViewDelegate>
    
    @property(nonatomic,strong)UIButton *btn1;
    @property(nonatomic,strong)UIButton *btn2;
    @property(nonatomic,strong)UILabel *label1;
    @property(nonatomic,strong)UILabel *label2;
    @property(nonatomic,strong)UILabel *label3;
    @property (nonatomic, strong) SGPageTitleView *pageTitleView;
    @end
    

    siTableViewCell.m

    #import "siTableViewCell.h"
    
    
    @implementation siTableViewCell
    
    -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
    {
        if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
            
            NSArray *titleArr = [@[@"全部", @"G/D/C", @"Z字头", @"T字头", @"K字头", @"其他"]mutableCopy];
            SGPageTitleViewConfigure *configure = [SGPageTitleViewConfigure pageTitleViewConfigure];
            configure.indicatorAdditionalWidth = 120;
            configure.spacingBetweenButtons = 20;
            configure.titleFont = [UIFont systemFontOfSize:17];
            configure.titleSelectedColor = [UIColor whiteColor];
            configure.indicatorColor = [UIColor colorWithRed:0/250.0 green:137/250.0 blue:211/250.0 alpha:1];
            configure.indicatorScrollStyle = SGIndicatorScrollStyleDefault;
            configure.indicatorStyle = SGIndicatorStyleCover;
            _pageTitleView.isOpenTitleTextZoom = YES;
            self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(10, 0, 394, 44) delegate:self titleNames:titleArr configure:configure];
            [self addSubview:_pageTitleView];
            
            _btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
            _btn1.frame = CGRectMake(20, 50, 35, 40);
            _btn1.tintColor = [UIColor orangeColor];
            [_btn1 setTitle:@"➕" forState:UIControlStateNormal];
            [_btn1 addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
            
            _label1 = [[UILabel alloc]init];
            _label1.text = @"乘客";
            _label1.textColor = [UIColor orangeColor];
            _label1.frame = CGRectMake(60, 50, 100, 40);
            
            _btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
            _btn2.frame = CGRectMake(10, 100, 394, 50);
            _btn2.backgroundColor = [UIColor colorWithRed:0/250.0 green:137/250.0 blue:211/250.0 alpha:1];
            _btn2.layer.cornerRadius = 10;
            [_btn2 setTitle:@"查询" forState:UIControlStateNormal];
    //        [_btn2 addTarget:self action:@selector(clicks) forControlEvents:UIControlEventTouchUpInside];
            
            _label2 = [[UILabel alloc]init];
            _label2.frame = CGRectMake(10, 160, 394, 40);
            _label2.text = @"-----------------                              -----------------";
            _label2.textColor = [UIColor colorWithRed:0/250.0 green:137/250.0 blue:211/250.0 alpha:1];
            
            _label3 = [[UILabel alloc]init];
            _label3.frame = CGRectMake(155, 160, 130, 40);
            _label3.text = @"最近常用路线";
            _label3.textColor = [UIColor grayColor];
            
            [self addSubview:self.btn1];
            [self addSubview:self.btn2];
            [self addSubview:self.label1];
            [self addSubview:self.label2];
            [self addSubview:self.label3];
        }
        return self;
    }
    
    -(void)click
    {
        NSLog(@"乘客");
    }
    
    
    
    @end
    

    wuTableViewCell.h

    #import <UIKit/UIKit.h>
    
    @interface wuTableViewCell : UITableViewCell
    
    @property(nonatomic,strong)UILabel * label1;
    @property(nonatomic,strong)UILabel * label2;
    @property(nonatomic,strong)UILabel * label3;
    
    
    @end
    
    

    wuTableViewCell.m

    #import "wuTableViewCell.h"
    
    @implementation wuTableViewCell
    
    -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
    {
        if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
            
            _label1 = [[UILabel alloc]init];
            _label1.frame = CGRectMake(0, 0, 100, 50);
            _label1.text = @"      前一天";
            _label1.textColor = [UIColor whiteColor];
            _label1.backgroundColor = [UIColor colorWithRed:90/255.0 green:175/255.0 blue:225/255.0 alpha:1];
            
            _label2 = [[UILabel alloc]init];
            _label2.frame = CGRectMake(100, 0, 214, 50);
            _label2.text = @"            2017-10-17";
            _label2.font = [UIFont systemFontOfSize:18];
            _label2.textColor = [UIColor whiteColor];
            _label2.backgroundColor = [UIColor colorWithRed:55/255.0 green:145/255.0 blue:205/255.0 alpha:1];
            
            _label3 = [[UILabel alloc]init];
            _label3.frame = CGRectMake(314, 0, 100, 50);
            _label3.text = @"      后一天";
            _label3.textColor = [UIColor whiteColor];
            _label3.backgroundColor = [UIColor colorWithRed:90/255.0 green:175/255.0 blue:225/255.0 alpha:1];
            
            [self addSubview:self.label1];
            [self addSubview:self.label2];
            [self addSubview:self.label3];
        }
        return self;
    }
    
    @end
    
    切片1副本.png

    相关文章

      网友评论

          本文标题:12306

          本文链接:https://www.haomeiwen.com/subject/ndryhftx.html