Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 157 lines (112 sloc) 6.225 kB
d993f0f @enriquez FIRST
enriquez authored
1 //
2 // ECSlidingViewController.h
3 // ECSlidingViewController
4 //
5 // Created by Michael Enriquez on 1/23/12.
6 // Copyright (c) 2012 EdgeCase. All rights reserved.
7 //
8
9 #import <UIKit/UIKit.h>
deed657 @enriquez Rename UIImage category
enriquez authored
10 #import "UIImage+ImageWithUIView.h"
d993f0f @enriquez FIRST
enriquez authored
11
1866b5a Post notifications for top view positions
Mike Enriquez + Leon Gersing authored
12 /** Notification that gets posted when the underRight view will appear */
13 extern NSString *const ECSlidingViewUnderRightWillAppear;
14
15 /** Notification that gets posted when the underLeft view will appear */
16 extern NSString *const ECSlidingViewUnderLeftWillAppear;
17
18 /** Notification that gets posted when the top view is anchored to the left side of the screen */
19 extern NSString *const ECSlidingViewTopDidAnchorLeft;
20
21 /** Notification that gets posted when the top view is anchored to the right side of the screen */
22 extern NSString *const ECSlidingViewTopDidAnchorRight;
23
24 /** Notification that gets posted when the top view is centered on the screen */
25 extern NSString *const ECSlidingViewTopDidReset;
26
b6b9da9 @enriquez New API with documentation
enriquez authored
27 /** @constant ECSide side of screen */
291cb37 @enriquez Simplify API and internals
enriquez authored
28 typedef enum {
b6b9da9 @enriquez New API with documentation
enriquez authored
29 /** Left side of screen */
30 ECLeft,
31 /** Right side of screen */
32 ECRight
33 } ECSide;
291cb37 @enriquez Simplify API and internals
enriquez authored
34
b6b9da9 @enriquez New API with documentation
enriquez authored
35 /** @constant ECResetStrategy top view behavior while anchored. */
36 typedef enum {
37 /** No reset strategy will be used */
38 ECNone = 0,
39 /** Tapping the top view will reset it */
40 ECTapping = 1 << 0,
41 /** Panning will be enabled on the top view. If it is panned and released towards the reset position it will reset, otherwise it will slide towards the anchored position. */
42 ECPanning = 1 << 1
43 } ECResetStrategy;
44
45 /** ECSlidingViewController is a view controller container that presents its child view controllers in two layers. The top layer can be panned to reveal the layers below it. */
2507f2a @leongersing Improved performance for drag behavior by delaying calls to cache the…
leongersing authored
46 @interface ECSlidingViewController : UIViewController{
47 CGPoint startTouchPosition;
48 BOOL topViewHasFocus;
49 }
d993f0f @enriquez FIRST
enriquez authored
50
b6b9da9 @enriquez New API with documentation
enriquez authored
51 /** Returns the view controller that will be visible when the top view is slide to the right.
52
53 This view controller is typically a menu or top-level view that switches out the top view controller.
54 */
d993f0f @enriquez FIRST
enriquez authored
55 @property (nonatomic, strong) UIViewController *underLeftViewController;
b6b9da9 @enriquez New API with documentation
enriquez authored
56
57 /** Returns the view controller that will be visible when the top view is slide to the left.
58
59 This view controller is typically a supplemental view to the top view.
60 */
642ff08 @enriquez Connect menu items to replace top view
enriquez authored
61 @property (nonatomic, strong) UIViewController *underRightViewController;
b6b9da9 @enriquez New API with documentation
enriquez authored
62
63 /** Returns the top view controller.
64
65 This is the main view controller that is presented above the other view controllers.
66 */
d993f0f @enriquez FIRST
enriquez authored
67 @property (nonatomic, strong) UIViewController *topViewController;
68
b6b9da9 @enriquez New API with documentation
enriquez authored
69 /** Returns the number of points the top view is visible when the top view is anchored to the left side.
70
71 This value is fixed after rotation. If the number of points to reveal needs to be fixed, use anchorLeftRevealAmount.
72
73 @see anchorLeftRevealAmount
74 */
75 @property (nonatomic, unsafe_unretained) CGFloat anchorLeftPeekAmount;
76
77 /** Returns the number of points the top view is visible when the top view is anchored to the right side.
78
79 This value is fixed after rotation. If the number of points to reveal needs to be fixed, use anchorRightRevealAmount.
80
81 @see anchorRightRevealAmount
82 */
83 @property (nonatomic, unsafe_unretained) CGFloat anchorRightPeekAmount;
84
85 /** Returns the number of points the under right view is visible when the top view is anchored to the left side.
86
87 This value is fixed after rotation. If the number of points to peek needs to be fixed, use anchorLeftPeekAmount.
88
89 @see anchorLeftPeekAmount
90 */
91 @property (nonatomic, unsafe_unretained) CGFloat anchorLeftRevealAmount;
92
93 /** Returns the number of points the under left view is visible when the top view is anchored to the right side.
94
95 This value is fixed after rotation. If the number of points to peek needs to be fixed, use anchorRightPeekAmount.
96
97 @see anchorRightPeekAmount
98 */
99 @property (nonatomic, unsafe_unretained) CGFloat anchorRightRevealAmount;
100
101 /** Specifies if the user should be able to interact with the top view when it is anchored.
102
103 By default, this is set to NO
104 */
105 @property (nonatomic, unsafe_unretained) BOOL shouldAllowUserInteractionsWhenAnchored;
106
107 /** Returns the strategy for resetting the top view when it is anchored.
108
109 By default, this is set to ECPanning | ECTapping to allow both panning and tapping to reset the top view.
110
111 If this is set to ECNone, then there must be a custom way to reset the top view otherwise it will stay anchored.
112 */
113 @property (nonatomic, unsafe_unretained) ECResetStrategy resetStrategy;
114
115 /** Returns a horizontal panning gesture for moving the top view.
116
117 This is typically added to the top view or a top view's navigation bar.
118 */
119 - (UIPanGestureRecognizer *)panGesture;
120
121 /** Slides the top view in the direction of the specified side.
122
123 A peek amount or reveal amount must be set for the given side. The top view will anchor to one of those specified values.
124
125 @param side The side for the top view to slide towards.
126 @param animations Perform changes to properties that will be animated while top view is moved off screen. Can be nil.
127 @param onComplete Executed after the animation is completed. Can be nil.
128 */
129 - (void)anchorTopViewTo:(ECSide)side animations:(void(^)())animations onComplete:(void(^)())complete;
130
131 /** Slides the top view off of the screen in the direction of the specified side.
132
133 @param side The side for the top view to slide off the screen towards.
134 @param animations Perform changes to properties that will be animated while top view is moved off screen. Can be nil.
135 @param onComplete Executed after the animation is completed. Can be nil.
136 */
137 - (void)anchorTopViewOffScreenTo:(ECSide)side animations:(void(^)())animations onComplete:(void(^)())complete;
138
139 /** Slides the top view back to the center. */
140 - (void)resetTopView;
d993f0f @enriquez FIRST
enriquez authored
141
b0bb27c @enriquez Expose BOOLs for inspecting view visibility
enriquez authored
142 /** Returns true if the underLeft view is showing (even partially) */
143 - (BOOL)underLeftShowing;
144
145 /** Returns true if the underRight view is showing (even partially) */
146 - (BOOL)underRightShowing;
147
148 /** Returns true if the top view is completely off the screen */
149 - (BOOL)topViewIsOffScreen;
150
d993f0f @enriquez FIRST
enriquez authored
151 @end
152
b6b9da9 @enriquez New API with documentation
enriquez authored
153 /** UIViewController extension */
d993f0f @enriquez FIRST
enriquez authored
154 @interface UIViewController(SlidingViewExtension)
b6b9da9 @enriquez New API with documentation
enriquez authored
155 /** Convience method for getting access to the ECSlidingViewController instance */
d993f0f @enriquez FIRST
enriquez authored
156 - (ECSlidingViewController *)slidingViewController;
157 @end
Something went wrong with that request. Please try again.