// 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;
}