This repository was archived by the owner on Mar 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathFSVerticalTabBarExampleController.m
More file actions
75 lines (59 loc) · 2.57 KB
/
FSVerticalTabBarExampleController.m
File metadata and controls
75 lines (59 loc) · 2.57 KB
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
//
// FSViewController.m
// FSVerticalTabBarExample
//
// Created by Truman, Christopher on 5/7/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "FSVerticalTabBarExampleController.h"
#import "FSVerticalTabBarController.h"
@interface FSVerticalTabBarExampleController () {
NSArray* viewControllers;
}
@end
@implementation FSVerticalTabBarExampleController
- (void)viewDidLoad
{
[super viewDidLoad];
self.delegate = self;
//Create view controllers
NSMutableArray* controllersToAdd = [[NSMutableArray alloc] init];
for (int i=0; i<4; i++) {
UIViewController * view = [[UIViewController alloc] init];
NSString * title = [NSString stringWithFormat:@"tab %d", i+1];
view.tabBarItem = [[UITabBarItem alloc] initWithTitle:title image:[UIImage imageNamed:@"magnifying-glass.png"] tag: 0];
[controllersToAdd addObject:view];
}
[((UIViewController*)[controllersToAdd objectAtIndex:0]).view setBackgroundColor:[UIColor blueColor]];
[((UIViewController*)[controllersToAdd objectAtIndex:1]).view setBackgroundColor:[UIColor redColor]];
[((UIViewController*)[controllersToAdd objectAtIndex:2]).view setBackgroundColor:[UIColor greenColor]];
[((UIViewController*)[controllersToAdd objectAtIndex:3]).view setBackgroundColor:[UIColor purpleColor]];
viewControllers = [NSArray arrayWithArray:controllersToAdd];
//set the view controllers of the the tab bar controller
[self setViewControllers:viewControllers];
//set the background color to a texture
//[[self tabBar] setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"ios-linen.png"]]];
NSArray *colors = [NSArray arrayWithObjects:(id)[UIColor whiteColor].CGColor,(id)[UIColor lightGrayColor].CGColor, nil];
self.tabBar.backgroundGradientColors = colors;
self.selectedViewController = ((UIViewController*)[viewControllers objectAtIndex:1]);
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
-(BOOL)tabBarController:(FSVerticalTabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
if ([viewControllers indexOfObject:viewController] == 3) {
return NO;
}
return YES;
}
@end