標(biāo)簽控制器簡(jiǎn)單搭建

// AppDelegate.m

#import "ViewController.h"

#import "LViewController.h"


//啟動(dòng)圖在屏幕顯示時(shí)間

sleep(0);

//判斷是不是第一次打開 如果不是就不顯示

//判斷是否是第一次不是就沒有啟動(dòng)動(dòng)畫

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:@"首頁(yè)" image:[UIImage imageNamed:@"2.png"] tag:1];

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

UITabBarItem *item3 = [[UITabBarItem alloc]initWithTitle:@"購(gòu)物車" 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"

{

//創(chuàng)建滑動(dòng)控件

UIScrollView *theScroll;

//分頁(yè)控件

UIPageControl *thePage;

//創(chuàng)建整型類

NSInteger tegPageTime;

//創(chuàng)建數(shù)組;

NSArray *theArray;

//計(jì)數(shù)器

NSTimer *theTime;

}


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

//獲取屏幕的寬

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

//獲取屏幕的高

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

//代替 初始化滾動(dòng)控件

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"],];

//將圖片與數(shù)組下標(biāo)綁定

theImg.image = theArray[i];

//將圖片添加到滾動(dòng)視圖中

[theScroll addSubview:theImg];

//設(shè)置滾動(dòng)視圖的坐標(biāo) 原代碼

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

X += width;

}

//設(shè)置滾動(dòng)視圖的大小

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

// 設(shè)置滾動(dòng)視圖按頁(yè)滾動(dòng)

theScroll.pagingEnabled = YES;

//滾動(dòng)條隱藏

theScroll.showsHorizontalScrollIndicator = NO;

//設(shè)置代理

theScroll.delegate = self;

//初始化頁(yè)碼

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

//頁(yè)數(shù)

thePage.numberOfPages = 4;

//初始頁(yè)第一頁(yè)

thePage.currentPage = 0;

//清除原來顏色

thePage.backgroundColor = [UIColor clearColor];

//沒動(dòng)原來

thePage.pageIndicatorTintColor = [UIColor greenColor];

//當(dāng)前翻頁(yè)顯示的顏色

thePage.currentPageIndicatorTintColor = [UIColor redColor];

//順序不能亂

[self.view addSubview:theScroll];

[self.view addSubview:thePage];

//記錄當(dāng)前圖片

tegPageTime = thePage.currentPage;

//第一個(gè)幾秒鐘換一下 事件

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];

}

//表示在滑動(dòng)滾動(dòng)視圖的時(shí)候調(diào)用此方法

- (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)

{

//停止圖片滾動(dòng)

[theTime setFireDate:[NSDate distantFuture]];

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

theBtn.backgroundColor = [UIColor orangeColor];

theBtn.layer.cornerRadius = 26;

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

//添加按鈕觸發(fā)事件:必須要用(UIControlEventTouchUpInside)

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

[self.view addSubview:theBtn];

//設(shè)置與用戶無法交互(這樣即可解決按鈕在前面的那頁(yè)中顯示)

//? scrollView.userInteractionEnabled = NO;

}

}

//實(shí)現(xiàn)頁(yè)碼和滾動(dòng)視圖的關(guān)聯(lián)

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollVie

{

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

}

//跳轉(zhuǎn)

-(void)TiaoZh

{

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

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

}


// myKuaiViewController.m

{

//cell每一行標(biāo)題

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

UIButton *buttonmoney,*BtnMy;

//橫排cell 按鈕

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

//按鈕 登錄 優(yōu)惠 積分

UIButton *BtnLoaing,*BtnYou,*BtnJi;

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

}

@property(nonatomic,strong)UITableView *table;


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

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

self.view.backgroundColor = [UIColor whiteColor];

_arrayOne= @[@"我的訂單"];

_arraytwo = @[@"地址管理",@"瀏覽記錄",@"查看評(píng)價(jià)"];

_arraythree = @[@"配送范圍",@"推薦有禮",@"積分商城",@"24小時(shí)客服電話"];

_arrayfour = @[@"設(shè)置"];

_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;

}

//表格每個(gè)分區(qū)

-(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;

}

//一共有幾個(gè)分區(qū)

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

{

return 4;

}

//每個(gè)分區(qū)返回的行數(shù)

-(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里的數(shù)據(jù)

-(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];

}

//第一個(gè)分區(qū)

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];

//點(diǎn)擊某一行不變顏色

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];

//優(yōu)惠

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"];

//當(dāng)前訂單

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 = @"當(dāng)前訂單";

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];

//待評(píng)價(jià)訂單

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 = @"待評(píng)價(jià)訂單";

lablefourDetext.textAlignment =? 1;

lablefourDetext.font = [UIFont systemFontOfSize:10];

[cell addSubview:buttonfour];

[cell addSubview:lablefourDetext];

}

}

//第二個(gè)分區(qū)

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"];

}

}

//第三個(gè)分區(qū)

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"];

}

//點(diǎn)擊每行后的背景顏色

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;

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 230,106評(píng)論 6 542
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 99,441評(píng)論 3 429
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 178,211評(píng)論 0 383
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)。 經(jīng)常有香客問我,道長(zhǎng),這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,736評(píng)論 1 317
  • 正文 為了忘掉前任,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 72,475評(píng)論 6 412
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 55,834評(píng)論 1 328
  • 那天,我揣著相機(jī)與錄音,去河邊找鬼。 笑死,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,829評(píng)論 3 446
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 43,009評(píng)論 0 290
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 49,559評(píng)論 1 335
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 41,306評(píng)論 3 358
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 43,516評(píng)論 1 374
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 39,038評(píng)論 5 363
  • 正文 年R本政府宣布,位于F島的核電站,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 44,728評(píng)論 3 348
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 35,132評(píng)論 0 28
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 36,443評(píng)論 1 295
  • 我被黑心中介騙來泰國(guó)打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 52,249評(píng)論 3 399
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 48,484評(píng)論 2 379

推薦閱讀更多精彩內(nèi)容