forked from romaonthego/REMenu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRootViewController.m
More file actions
102 lines (85 loc) · 4.15 KB
/
RootViewController.m
File metadata and controls
102 lines (85 loc) · 4.15 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//
// RootViewController.m
// REMenuExample
//
// Created by Roman Efimov on 2/20/13.
// Copyright (c) 2013 Roman Efimov. All rights reserved.
//
#import "RootViewController.h"
@implementation RootViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithWhite:0.902 alpha:1.000];
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0 green:179/255.0 blue:134/255.0 alpha:1];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Menu" style:UIBarButtonItemStyleBordered target:self action:@selector(showMenu)];
}
- (void)showMenu
{
if (_menu.isOpen)
return [_menu close];
// Sample icons from http://icons8.com/download-free-icons-for-ios-tab-bar
//
REMenuItem *homeItem = [[REMenuItem alloc] initWithTitle:@"Home"
subtitle:@"Return to Home Screen"
image:[UIImage imageNamed:@"Icon_Home"]
highlightedImage:nil
action:^(REMenuItem *item) {
NSLog(@"Item: %@", item);
}];
REMenuItem *exploreItem = [[REMenuItem alloc] initWithTitle:@"Explore"
subtitle:@"Explore 47 additional options"
image:[UIImage imageNamed:@"Icon_Explore"]
highlightedImage:nil
action:^(REMenuItem *item) {
NSLog(@"Item: %@", item);
}];
REMenuItem *activityItem = [[REMenuItem alloc] initWithTitle:@"Activity"
subtitle:@"Perform 3 additional activities"
image:[UIImage imageNamed:@"Icon_Activity"]
highlightedImage:nil
action:^(REMenuItem *item) {
NSLog(@"Item: %@", item);
}];
REMenuItem *profileItem = [[REMenuItem alloc] initWithTitle:@"Profile"
image:[UIImage imageNamed:@"Icon_Profile"]
highlightedImage:nil
action:^(REMenuItem *item) {
NSLog(@"Item: %@", item);
}];
// You can also assign custom view for items
// Uncomment the code below and add customViewItem to `initWithItems` array, e.g.
// [[REMenu alloc] initWithItems:@[homeItem, exploreItem, activityItem, profileItem, customViewItem]]
//
/*
UIView *customView = [[UIView alloc] init];
customView.backgroundColor = [UIColor blueColor];
customView.alpha = 0.4;
REMenuItem *customViewItem = [[REMenuItem alloc] initWithCustomView:customView action:^(REMenuItem *item) {
NSLog(@"Tap on customView");
}];
*/
homeItem.tag = 0;
exploreItem.tag = 1;
activityItem.tag = 2;
profileItem.tag = 3;
_menu = [[REMenu alloc] initWithItems:@[homeItem, exploreItem, activityItem, profileItem]];
_menu.cornerRadius = 4;
_menu.shadowRadius = 4;
_menu.shadowColor = [UIColor blackColor];
_menu.shadowOffset = CGSizeMake(0, 1);
_menu.shadowOpacity = 1;
_menu.imageOffset = CGSizeMake(5, -1);
[_menu showFromNavigationController:self.navigationController];
}
#pragma mark -
#pragma mark Rotation
- (BOOL)shouldAutorotate
{
return YES;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return YES;
}
@end