高仿人寿保险界面

第一步 首先导入第三方 gd
第二步 创建3个继承于UIViewController的类 分别为
oneViewController twoViewController threeViewController
第三步 在ViewController.m里
viewDidLoad [self createTabbar];
其次代码块

-(void)createTabbar{
    NSArray *array = @[@"oneViewController",@"twoViewController",@"threeViewController"];
    //点击前的样式
    NSArray *unSelectedImagerArray = @[@"首页",@"金融超市",@"个人中心"];
    //点击后的样式
    NSArray *SelectedImagerArray = @[@"首页",@"金融超市",@"个人中心"];
    
    //控制器数组
    NSMutableArray *ViewContro = [NSMutableArray new];
    
    //根据控制器的名称创建响应的控制器 并添加到控制器的数组里
    for (int i = 0; i<array.count; i++) {
        //string ----> Controller
        UIViewController *vc = [[NSClassFromString(array[i]) alloc]init];
        UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
        //设置Tabbritem  的 选中图片 未选中图片 标题
        nav.tabBarItem.image = [[UIImage imageNamed:unSelectedImagerArray[i] ] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        nav.tabBarItem.selectedImage = [[UIImage imageNamed:SelectedImagerArray [i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        nav.title = unSelectedImagerArray[i];
        // nav.navigationBar.barTintColor = [UIColor blackColor];
        //添加到数组里
        [ViewContro addObject:nav];
        
        
        
    }
    self.tabBar.barTintColor = [UIColor redColor];
    self.viewControllers = ViewContro;
    self.selectedIndex = 1;
}

第四步 在twoViewController.m里

#import "CarouseView.h"
#import "CarouseViewPlus.h"
#define HCWidth self.view.frame.size.width
#define HCHeigth self.view.frame.size.height
<UITableViewDelegate,UITableViewDataSource,UICollectionViewDelegate,UICollectionViewDataSource,CarouseViewDataSource, CarouseViewDelegate>
{
    // 轮播图变量,其实作为局部变量也行
    CarouseView *carouseView;
    CarouseViewPlus *carouseViewPlus;
    
    // 轮播图相关的数据
    NSArray *kvDataArray;
}

@property (nonatomic , strong)UICollectionView *clv;
@property (strong, nonatomic) UIView *contentView;
@property (strong, nonatomic) UIButton *popBtn;
@property (nonatomic, strong)UITableView *tbv;

viewDidLoad里

[self gundong];
    [self.view addSubview:self.tbv];
    self.title = @"万家灯火";
    self.navigationController.navigationBar.titleTextAttributes=
    @{NSForegroundColorAttributeName:[UIColor whiteColor],
      NSFontAttributeName:[UIFont systemFontOfSize:22]};
    self.navigationController.navigationBar.barTintColor = [UIColor redColor];

代码块:

-(UITableView *)tbv{
    if (!_tbv) {
        _tbv = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, HCWidth, HCHeigth) style:UITableViewStylePlain];
        _tbv.dataSource = self;
        _tbv.delegate = self;
    }
    return _tbv;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 4;
}
-(void)gundong{
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 280)];
    // 添加轮播图1
    kvDataArray = @[@"page 1", @"page 2", @"page3", @"page 4", @"page 5"];
    carouseView = [[CarouseView alloc] init];
    carouseView.frame = CGRectMake(0, 0, self.view.frame.size.width, 170);
    carouseView.datasource = self;
    carouseView.delegate = self;
    [headerView addSubview:carouseView];
    
    
    UIView * view  =[[UIView alloc]initWithFrame:CGRectMake(0, 170, self.view.frame.size.width, 110)];
    // view.backgroundColor = [UIColor blueColor];
    NSArray *arr  = @[@"11",@"22",@"33",@"44"];
    NSArray *arr1 = @[@"保险精品",@"课程精品",@"车险定制",@"关于我们"];
    for (int i = 0; i<arr.count; i++) {
        
        UIButton *bu = [[UIButton alloc]initWithFrame:CGRectMake(15 + 100*i, 10, 70, 70)];
        
        
        [bu setBackgroundImage:[UIImage imageNamed:arr[i]] forState:UIControlStateNormal];
        
        [view addSubview:bu];
        UILabel *l1 = [[UILabel alloc]initWithFrame:CGRectMake(15 + 100*i, 85, 70, 20)];
        
        [l1 setText:arr1[i]];
        [view addSubview:l1];
        
    }
    [headerView addSubview:view];
    self.tbv.tableHeaderView = headerView;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
        
    }
    
    if (indexPath.row == 0) {
        _tbv.rowHeight = 30;
        cell.textLabel.text = @"| 热销产品";
        cell.backgroundColor = [UIColor colorWithRed:255.0/255 green:196.0/255 blue:190.0/255 alpha:1];
    }else if(indexPath.row == 1){
        _tbv.rowHeight = 150;
        UIImageView *img1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 150)];
        img1.image = [UIImage imageNamed:@"aaaa"];
        [cell addSubview:img1];
    }else if (indexPath.row == 2){
        _tbv.rowHeight = 150;
        UIImageView *img2 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 150)];
        img2.image = [UIImage imageNamed:@"bbbb"];
        [cell addSubview:img2];
    }else{
        _tbv.rowHeight = 150;
        UIImageView *img3 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 150)];
        img3.image = [UIImage imageNamed:@"cccc"];
        [cell addSubview:img3];
    }
    
    
    
    
    
    return cell;
}

#pragma mark - 轮播图代理
- (NSInteger)countOfCellForCarouseView:(CarouseView *)carouseView
{
    return kvDataArray.count;
}

- (UIView *)carouselView:(CarouseView *)carouselView cellAtIndex:(NSInteger)index
{
    // 先用空白页测试
    //    UIView *imageView = [[UIView alloc] init];
    //    int R = (arc4random() % 256) ;
    //    int G = (arc4random() % 256) ;
    //    int B = (arc4random() % 256) ;
    //    imageView.backgroundColor = [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:1];
    
    // 填充view,可以是任意view
    UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%ld.jpg", (long)index + 1]];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 50, 100, 50)];
    label.text = kvDataArray[index];
    [imageView addSubview:label];
    
    return imageView;
}

- (void)carouseView:(CarouseView *)carouseView didSelectedAtIndex:(NSInteger)index
{
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"carouse1 msg"
                                                        message:kvDataArray[index]
                                                       delegate:nil
                                              cancelButtonTitle:@"ok"
                                              otherButtonTitles:nil, nil];
    [alertView show];
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值