• Stars
    star
    851
  • Rank 53,558 (Top 2 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created about 11 years ago
  • Updated about 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Side Menus for iOS 7

TWTSideMenuViewController

Build Status

One of the most common implementations of menu views has been the "Side Drawer", "basement", or "Side Menu" made popular in apps such as Facebook and Path. When the user taps to open the side menu the user's main context slides to the right (or left in some implementations) to display another view below. This works well in iOS 6 and before. What does it mean for iOS 7?

With iOS 7, apps are encouraged to use the whole screen and not rely on the 20pt status bar to be outside of the plane of your app. This breaks the existing side bar idea in that the status bar now lives over two view contexts with a single style.

Bad Side Bar

Working with the team at Luvocracy, we needed to find a way to show a side menu for our iOS 7 release. Many designers on Dribbble began looking at a new approach for side bars. Inspired by this we worked up a quick prototype that slides the view to the right and scales revealing the menu as seen in the dribbble samples above. Moving forward from this idea and inspired by other ideas from iOS 7 we changed it from a slide to more of a viewport change.

SideMenuViewController

Usage

TWTSideMenuViewController is implemented using a single parent view controller that manages your menu and main views as child view controllers. To set it up, initialize a new instance of TWTSideMenuViewController and supply a menu view controller and a main view controller.

  // application:didFinishLaunchingWithOptions:

  self.menuViewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
  self.mainViewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
  
  // create a new side menu
  self.sideMenuViewController = [[TWTSideMenuViewController alloc] initWithMenuViewController:self.menuViewController mainViewController:[[UINavigationController alloc] initWithRootViewController:self.mainViewController]];

  // specify the shadow color to use behind the main view controller when it is scaled down.
  self.sideMenuViewController.shadowColor = [UIColor blackColor];

  // specify a UIOffset to offset the open position of the menu
  self.sideMenuViewController.edgeOffset = UIOffsetMake(18.0f, 0.0f);

  // specify a scale to zoom the interface — the scale is 0.0 (scaled to 0% of it's size) to 1.0 (not scaled at all). The example here specifies that it zooms so that the main view is 56.34% of it's size in open mode. 
  self.sideMenuViewController.zoomScale = 0.5634f;

  // set the side menu controller as the root view controller
  self.window.rootViewController = self.sideMenuViewController;

Later, when you need to change what is in the main view controller's context you can simply set the view controller with the convenience method:

  // All views presented in a side menu view controller have access to the side menu directly. Much like the way UINavigationController works. To swap to a new view controller simply set the main view controller:

  [self.sideMenuViewController setMainViewController:controller animated:YES closeMenu:YES];

TODO

  • Find additional requirements as the library is used in additional apps. (This initial version was built to meet the needs of a single app).
  • Add Tests

Requirements

  • Base SDK: iOS 7
  • Deployment Target: iOS 6+

Contact

TWTSideMenuViewController was created by Two Toasters in the development of Luvocracy.

License

Available under the MIT License. See the LICENSE file for more.

More Repositories

1

JazzyListView

Java
935
star
2

TTSwitch

Fully customizable switch for iOS using images
Objective-C
432
star
3

clusterkraf

A clustering library for the Google Maps Android API v2
Java
255
star
4

SectionCursorAdapter

Java
110
star
5

multi-column-list-adapter

Java
100
star
6

TTAlertView

Objective-C
82
star
7

watchface-template

Java
79
star
8

Toast

Tools and Utilities for Cocoa Development
Objective-C
67
star
9

RecyclerViewLib

An example implementation of Android's new RecyclerView.
Java
63
star
10

HorizontalImageScroller-Android

A horizontal image scroller widget for Android
Java
50
star
11

MaterialRangeSlider

Material inspired range slider
Java
42
star
12

Wear-MessageApiDemo

Java
36
star
13

zbar

git clone of zbar sdk
Objective-C
35
star
14

AnimatedPath

Objective-C
33
star
15

AndroidStyleGuidelines

31
star
16

AndrOAuth

Java
29
star
17

hoot

A powerful, flexible, lightweight Android library for dealing with RESTful endpoints.
Java
26
star
18

watchface-gears

Java
20
star
19

UISpec

Git SVN Clone of UISpec
Objective-C
19
star
20

UISpecRunner

Flexible CLI test runner for UISpec
Ruby
16
star
21

FramerateDemo

Objective-C
11
star
22

toastdroid

Java
9
star
23

HelloAndroidStudio

Java
8
star
24

objective_stack

A Rails template used by the fine folks at Two Toasters
Ruby
7
star
25

TWTCommon

Misc. downright useful classes & additions for iphone development (with three 20)
Objective-C
7
star
26

project-example

Example repository demonstrating the twotoasters development process
6
star
27

Android-Master-Class-ListenerAwareAsyncTask

Java
6
star
28

fbconnect-iphone

Facebook Connect for iPhone
Objective-C
5
star
29

AnalyticsTest

Java
5
star
30

chron

Java
2
star
31

resource_controller_extensions

Provides reasonable default handlers for XML, JSON, and FBML to ResourceController
Ruby
2
star
32

iPhone-Build-Scripts

client build and release build scripts for iphone projects
Ruby
1
star
33

facebook-ios-sdk-framework

*Unofficial* build of the Facebook iOS SDK Framework
Objective-C
1
star
34

RKCatalog-Server

Simple Sinatra backend for the RestKit RKCatalog Sample app
Ruby
1
star
35

brominet

Objective-C
1
star
36

Xcode-Templates

Objective-C
1
star
37

Volley

Java
1
star