forked from hackxhj/HighCopyTodayNews
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TTTabBarController.m
executable file
·86 lines (62 loc) · 3.02 KB
/
TTTabBarController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//
// MainTabViewController.m
// HighCopyTodayNews
//
// Created by hack on 2017/7/28.
// Copyright © 2017年 hack. All rights reserved.
//
#import "TTTabBarController.h"
#import "TTTabbar.h"
#import "TTTabBarItem.h"
#import "ArticleTabBarStyleNewsListViewController.h"
@interface TTTabBarController ()<TTTabbarDelegate>
@property(nonatomic,strong)TTTabbar *tttabBar;
@end
@implementation TTTabBarController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
TTTabbar *tttabBar = [[TTTabbar alloc] initWithFrame:self.tabBar.frame];
tttabBar.ydelegate=self;
[self setValue:tttabBar forKeyPath:@"tabBar"];
self.tttabBar=tttabBar;
[self initTabItems];
}
-(void)initTabItems{
ArticleTabBarStyleNewsListViewController *homeVC=[ArticleTabBarStyleNewsListViewController new];
UIViewController *watermelonVC=[UIViewController new];
watermelonVC.view.backgroundColor=[UIColor yellowColor];
UIViewController *weiheadlineVC=[UIViewController new];
UIViewController *smallvideoVC=[UIViewController new];
NSArray *viewControllers = @[homeVC, watermelonVC, weiheadlineVC,smallvideoVC];
NSMutableArray *tabBarVcs = [[NSMutableArray alloc] initWithCapacity:4];
for (int i = 0; i < viewControllers.count; i++) {
UIViewController *viewController = viewControllers[i];
UINavigationController *navgationController = [[UINavigationController alloc] initWithRootViewController:viewController];
navgationController.navigationBar.translucent=NO;
navgationController.navigationBar.barTintColor=[UIColor whiteColor];
[tabBarVcs addObject:navgationController];
}
self.viewControllers = tabBarVcs;
TTTabBarItem *one1=[[TTTabBarItem alloc]initWithTitle:@"首页" image:[UIImage imageNamed:@"home_tabbar"] selectedImage:[UIImage imageNamed:@"home_tabbar_press"]];
TTTabBarItem *one2=[[TTTabBarItem alloc]initWithTitle:@"西瓜视频" image:[UIImage imageNamed:@"video_tabbar"] selectedImage:[UIImage imageNamed:@"video_tabbar_press"]];
TTTabBarItem *one3=[[TTTabBarItem alloc]initWithTitle:@"微头条" image:[UIImage imageNamed:@"weitoutiao_tabbar"] selectedImage:[UIImage imageNamed:@"weitoutiao_tabbar_press"]];
TTTabBarItem *one4=[[TTTabBarItem alloc]initWithTitle:@"小视频" image:[UIImage imageNamed:@"huoshan_tabbar"] selectedImage:[UIImage imageNamed:@"huoshan_tabbar_press"]];
self.tttabBar.tabItems=@[one1,one2,one3,one4];
}
-(void)didSelectedItem:(NSInteger)index{
self.selectedIndex=index;
}
- (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