标签控制器简单搭建

// AppDelegate.m

#import "ViewController.h"

#import "LViewController.h"


//启动图在屏幕显示时间

sleep(0);

//判断是不是第一次打开 如果不是就不显示

//判断是否是第一次不是就没有启动动画

BOOL show=[[NSUserDefaults standardUserDefaults] objectForKey:@"show"];

if(show==NO)

{

[[NSUserDefaults standardUserDefaults]setBool:YES forKey:@"show"];

LViewController *st=[LViewController new];

self.window.rootViewController=st;

}

else

{

ViewController *vc = [[ViewController alloc] init];

self.window.rootViewController = vc;

}


// ViewController.m

#import "oneViewController.h"

#import "twoViewController.h"

#import "threeViewController.h"

#import "myKuaiViewController.h"


oneViewController *one = [[oneViewController alloc]init];

twoViewController *fenLei = [[twoViewController alloc] init];

threeViewController *gouWuChe = [[threeViewController alloc]init];

myKuaiViewController *myKuaiF = [[myKuaiViewController alloc]init];

UINavigationController *navo = [[UINavigationController alloc]initWithRootViewController:one];

UINavigationController *navf = [[UINavigationController alloc]initWithRootViewController:fenLei];

UINavigationController *navg = [[UINavigationController alloc]initWithRootViewController:gouWuChe];

UINavigationController *navm = [[UINavigationController alloc]initWithRootViewController:myKuaiF];

myKuaiF.tabBarItem.image = [UIImage imageNamed:@"2"];

myKuaiF.title = @"我的快方";

UITabBarItem *item1 = [[UITabBarItem alloc]initWithTitle:@"首页" image:[UIImage imageNamed:@"2.png"] tag:1];

UITabBarItem *item2 = [[UITabBarItem alloc]initWithTitle:@"分类" image:[UIImage imageNamed:@"2.png"] tag:1];

UITabBarItem *item3 = [[UITabBarItem alloc]initWithTitle:@"购物车" image:[UIImage imageNamed:@"2"] tag:1];

//    UITabBarItem *item4 = [[UITabBarItem alloc]initWithTitle:@"我的快方" image:[UIImage imageNamed:@"4.png"] tag:1];

navo.tabBarItem = item1;

navf.tabBarItem = item2;

navg.tabBarItem = item3;

//    navm.tabBarItem = item4;

self.viewControllers = @[navo,navf,navg,myKuaiF];


//轮播图// LViewController.m

#import "oneViewController.h"

#import "ViewController.h"

{

//创建滑动控件

UIScrollView *theScroll;

//分页控件

UIPageControl *thePage;

//创建整型类

NSInteger tegPageTime;

//创建数组;

NSArray *theArray;

//计数器

NSTimer *theTime;

}


//=============================

//获取屏幕的宽

float width = self.view.frame.size.width;

//获取屏幕的高

float height = self.view.frame.size.height;

//代替 初始化滚动控件

theScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, width, height)];

//获取屏幕X轴

float X = 0.0;

//一共四张图片

for (int i = 0; i < 4; i++)

{

//图片初始化

UIImageView *theImg = [[UIImageView alloc] initWithFrame:CGRectMake(X, 0, width, height)];

//将图片添加到视图里

theArray = @[[UIImage imageNamed:@"2"],[UIImage imageNamed:@"2"],[UIImage imageNamed:@"2"],[UIImage imageNamed:@"2"],];

//将图片与数组下标绑定

theImg.image = theArray[i];

//将图片添加到滚动视图中

[theScroll addSubview:theImg];

//设置滚动视图的坐标 原代码

//(width=self.view.frame.size.width+self.view.frame.size.width+self.view.frame.size.width+self.view.frame.size.width,)

X += width;

}

//设置滚动视图的大小

theScroll.contentSize = CGSizeMake(width * 4, height);

// 设置滚动视图按页滚动

theScroll.pagingEnabled = YES;

//滚动条隐藏

theScroll.showsHorizontalScrollIndicator = NO;

//设置代理

theScroll.delegate = self;

//初始化页码

thePage = [[UIPageControl alloc]initWithFrame:CGRectMake(width /2-50, 570, 100, 30)];

//页数

thePage.numberOfPages = 4;

//初始页第一页

thePage.currentPage = 0;

//清除原来颜色

thePage.backgroundColor = [UIColor clearColor];

//没动原来

thePage.pageIndicatorTintColor = [UIColor greenColor];

//当前翻页显示的颜色

thePage.currentPageIndicatorTintColor = [UIColor redColor];

//顺序不能乱

[self.view addSubview:theScroll];

[self.view addSubview:thePage];

//记录当前图片

tegPageTime = thePage.currentPage;

//第一个几秒钟换一下 事件

theTime = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(scroll) userInfo:nil repeats:YES];

/////==================================

//事件

-(void)scroll

{

tegPageTime ++;

if (tegPageTime>=theArray.count)

{

tegPageTime = 0;

}

[theScroll setContentOffset:CGPointMake(tegPageTime*theScroll.frame.size.width, 0) animated:YES];

}

//表示在滑动滚动视图的时候调用此方法

- (void)scrollViewDidScroll:(UIScrollView *)scrollView

{

CGPoint point=scrollView.contentOffset;//偏移

//获得所在位置

thePage.currentPage=point.x / scrollView.frame.size.width;

UIButton *theBtn = [[UIButton alloc]init];

if (thePage.currentPage == 3)

{

//停止图片滚动

[theTime setFireDate:[NSDate distantFuture]];

theBtn.frame = CGRectMake(133, 653, 150, 50);

theBtn.backgroundColor = [UIColor orangeColor];

theBtn.layer.cornerRadius = 26;

[theBtn setTitle:@"立即登录" forState:UIControlStateNormal];

//添加按钮触发事件:必须要用(UIControlEventTouchUpInside)

[theBtn addTarget:self action:@selector(TiaoZh) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:theBtn];

//设置与用户无法交互(这样即可解决按钮在前面的那页中显示)

//  scrollView.userInteractionEnabled = NO;

}

}

//实现页码和滚动视图的关联

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollVie

{

thePage.currentPage = theScroll.contentOffset.x / self.view.frame.size.width;

}

//跳转

-(void)TiaoZh

{

ViewController *VC = [[ViewController alloc]init];

[self presentViewController:VC animated:YES completion:nil];

}


// myKuaiViewController.m

{

//cell每一行标题

NSArray *_array, *_arrayOne,*_arraytwo,*_arraythree,*_arrayfour,*_arrayfive;

UIButton *buttonmoney,*BtnMy;

//横排cell 按钮

UIButton *buttonone,*buttontwo,*buttonthree,*buttonfour;

//按钮 登录 优惠 积分

UIButton *BtnLoaing,*BtnYou,*BtnJi;

UILabel *lableoneDetext,*labletwoDetext,*lablethreeDetext,*lablefourDetext;

}

@property(nonatomic,strong)UITableView *table;


//=============================

self.title = @"我的快方";

self.view.backgroundColor = [UIColor whiteColor];

_arrayOne= @[@"我的订单"];

_arraytwo = @[@"地址管理",@"浏览记录",@"查看评价"];

_arraythree = @[@"配送范围",@"推荐有礼",@"积分商城",@"24小时客服电话"];

_arrayfour = @[@"设置"];

_table = [[UITableView alloc]initWithFrame:CGRectMake(0, -8, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];

_table.delegate = self;

_table.dataSource = self;

//添加视图

[self.view addSubview:_table];

=========================

//每行cell高度

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

if(indexPath.section == 0)

{

if (indexPath.row == 0)

{

return 160;

}

}

else if (indexPath.section == 1)

{

return 53;

}

return 53;

}

//表格每个分区

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

{

if(section == 0)

{

//返回的是最上边的登录

return 10;

}

else if (section == 1)

{

return 0.01;

}else if (section == 2)

{

return 0.01;

}else if (section == 3)

{

return 0.01;

}

return 21;

}

//一共有几个分区

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

{

return 4;

}

//每个分区返回的行数

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

if (section ==0)

{

return 3;

}else if (section == 1)

{

return _arraytwo.count;

}else if (section == 2)

{

return _arraythree.count;

}else if (section == 3)

{

return _arrayfour.count;

}

return _array.count;

}

//cell里的数据

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

static NSString *string = @"string";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:string];

if (!cell)

{

cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:string];

}

//第一个分区

if (indexPath.section== 0)

{

if (indexPath.row == 0)

{

UIView *ViewH = [[UIView alloc]initWithFrame:CGRectMake(0,0,self.view.frame.size.width, 160)];

ViewH.backgroundColor = [UIColor redColor];

[cell.contentView addSubview:ViewH];

//点击某一行不变颜色

cell.selectionStyle = UITableViewCellSelectionStyleNone;

//登录按钮

BtnLoaing = [UIButton buttonWithType:UIButtonTypeCustom];

BtnLoaing.frame = CGRectMake(15, 55, 130, 50);

[BtnLoaing setImage:[UIImage imageNamed:@"2.png"] forState:UIControlStateNormal];

[BtnLoaing addTarget:self action:@selector(Denglu) forControlEvents:UIControlEventTouchUpInside];

[ViewH addSubview:BtnLoaing];

//优惠

BtnYou = [UIButton buttonWithType:UIButtonTypeCustom];

BtnYou.frame = CGRectMake(15, 115, 50, 20);

[BtnYou setImage:[UIImage imageNamed:@"2.png"] forState:UIControlStateNormal];

[BtnYou addTarget:self action:@selector(YouHui) forControlEvents:UIControlEventTouchUpInside];

[ViewH addSubview:BtnYou];

UILabel *la = [[UILabel alloc] initWithFrame:CGRectMake(128, 120, 8,14)];

la.text = @"|";

la.textColor = [UIColor whiteColor];

[ViewH addSubview:la];

//积分

BtnJi = [UIButton buttonWithType:UIButtonTypeCustom];

BtnJi.frame = CGRectMake(195, 115, 50, 20);

[BtnJi setImage:[UIImage imageNamed:@"2.png"] forState:UIControlStateNormal];

[BtnJi addTarget:self action:@selector(JiFen) forControlEvents:UIControlEventTouchUpInside];

[ViewH addSubview:BtnJi];

}

//我的订单

else if (indexPath.row == 1)

{

cell.textLabel.text = @"我的订单";

}

//横排各种订单

else if (indexPath.row == 2)

{

//            cell.textLabel.text = _arrayOne[indexPath.row];

//            cell.imageView.image = [UIImage imageNamed:@"分类.png"];

//当前订单

buttonone = [[UIButton alloc]initWithFrame:CGRectMake(-15, 0, self.view.frame.size.width/3, 35)];

[buttonone setImage:[UIImage imageNamed:@"2.png"] forState:UIControlStateNormal];

[buttonone setTitleColor:[UIColor colorWithRed:0.61f green:0.36f blue:0.01f alpha:1.0f]forState:UIControlStateNormal];  //正常情况

[buttonone addTarget:self action:@selector(current) forControlEvents:UIControlEventTouchUpInside];

buttonone.adjustsImageWhenHighlighted = YES;

lableoneDetext = [[UILabel alloc]initWithFrame:CGRectMake(-15, 35, self.view.frame.size.width/3, 10)];

lableoneDetext.text = @"当前订单";

lableoneDetext.textAlignment =  1;

lableoneDetext.font = [UIFont systemFontOfSize:10];

[cell addSubview:buttonone];

[cell addSubview:lableoneDetext];

//待付款订单

buttontwo = [[UIButton alloc]initWithFrame:CGRectMake(85, 0, self.view.frame.size.width/3, 35)];

[buttontwo setImage:[UIImage imageNamed:@"2.png"] forState:UIControlStateNormal];

[buttontwo setTitleColor:[UIColor colorWithRed:0.61f green:0.36f blue:0.01f alpha:1.0f]forState:UIControlStateNormal];  //正常情况

[buttontwo addTarget:self action:@selector(pending) forControlEvents:UIControlEventTouchUpInside];

buttontwo.adjustsImageWhenHighlighted = YES;

labletwoDetext = [[UILabel alloc]initWithFrame:CGRectMake(85, 35, self.view.frame.size.width/3, 10)];

labletwoDetext.text = @"待付款订单";

labletwoDetext.textAlignment =  1;

labletwoDetext.font = [UIFont systemFontOfSize:10];

[cell addSubview:buttontwo];

[cell addSubview:labletwoDetext];

//已完成订单

buttonthree = [[UIButton alloc]initWithFrame:CGRectMake(185, 0, self.view.frame.size.width/3, 35)];

[buttonthree setImage:[UIImage imageNamed:@"2.png"] forState:UIControlStateNormal];

[buttonthree setTitleColor:[UIColor colorWithRed:0.61f green:0.36f blue:0.01f alpha:1.0f]forState:UIControlStateNormal];  //正常情况

[buttonthree addTarget:self action:@selector(over) forControlEvents:UIControlEventTouchUpInside];

buttonthree.adjustsImageWhenHighlighted = YES;

lablethreeDetext = [[UILabel alloc]initWithFrame:CGRectMake(185, 35, self.view.frame.size.width/3, 10)];

lablethreeDetext.text = @"已完成订单";

lablethreeDetext.textAlignment =  1;

lablethreeDetext.font = [UIFont systemFontOfSize:10];

[cell addSubview:buttonthree];

[cell addSubview:lablethreeDetext];

//待评价订单

buttonfour = [[UIButton alloc]initWithFrame:CGRectMake(275, 0, self.view.frame.size.width/3, 35)];

[buttonfour setImage:[UIImage imageNamed:@"2.png"] forState:UIControlStateNormal];

[buttonfour setTitleColor:[UIColor colorWithRed:0.61f green:0.36f blue:0.01f alpha:1.0f]forState:UIControlStateNormal];  //正常情况

[buttonfour addTarget:self action:@selector(evaluate) forControlEvents:UIControlEventTouchUpInside];

buttonfour.adjustsImageWhenHighlighted = YES;

lablefourDetext = [[UILabel alloc]initWithFrame:CGRectMake(275, 35, self.view.frame.size.width/3, 10)];

lablefourDetext.text = @"待评价订单";

lablefourDetext.textAlignment =  1;

lablefourDetext.font = [UIFont systemFontOfSize:10];

[cell addSubview:buttonfour];

[cell addSubview:lablefourDetext];

}

}

//第二个分区

else if (indexPath.section ==1)

{

cell.textLabel.text = _arraytwo[indexPath.row];

if (indexPath.row == 0)

{

cell.imageView.image = [UIImage imageNamed:@"2.png"];

}

else if (indexPath.row == 1)

{

cell.imageView.image = [UIImage imageNamed:@"2.png"];

}

else if (indexPath.row == 2)

{

cell.imageView.image = [UIImage imageNamed:@"2.png"];

}

}

//第三个分区

else

if (indexPath.section ==2)

{

cell.textLabel.text = _arraythree[indexPath.row];

cell.imageView.image = [UIImage imageNamed:@"2.png"];

}

else

if (indexPath.section ==3)

{

if (indexPath.row == 0)

{

}

cell.textLabel.text = _arrayfour[indexPath.row];

cell.imageView.image = [UIImage imageNamed:@"2.png"];

}

//点击每行后的背景颜色

cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];

cell.selectedBackgroundView.backgroundColor = [UIColor colorWithRed:236/255.0 green:236/255.0 blue:236/255.0 alpha:0.5];

return cell;

}

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,222评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,455评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,720评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,568评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,696评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,879评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,028评论 3 409
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,773评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,220评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,550评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,697评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,360评论 4 332
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,002评论 3 315
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,782评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,010评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,433评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,587评论 2 350

推荐阅读更多精彩内容