Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 200 lines (168 sloc) 10.041 kb
b645dd5 @myell0w Initial Commit: Black or Gray Status Bar Overlay that can change it's…
authored
1 //
a5bc31b @myell0w added License
authored
2 // MTStatusBarOverlay.m
b645dd5 @myell0w Initial Commit: Black or Gray Status Bar Overlay that can change it's…
authored
3 //
4 // Created by Matthias Tretter on 27.09.10.
8cec5ba @myell0w Updated Copyright
authored
5 // Copyright (c) 2009-2011 Matthias Tretter, @myell0w. All rights reserved.
b645dd5 @myell0w Initial Commit: Black or Gray Status Bar Overlay that can change it's…
authored
6 //
526aed2 @myell0w Changed MTStatusBarOverlay to be a Singleton, minor changes and comme…
authored
7 // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
a5bc31b @myell0w added License
authored
8 // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10 // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
526aed2 @myell0w Changed MTStatusBarOverlay to be a Singleton, minor changes and comme…
authored
11 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
a5bc31b @myell0w added License
authored
12 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
13 // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
526aed2 @myell0w Changed MTStatusBarOverlay to be a Singleton, minor changes and comme…
authored
14 //
15 // Credits go to:
6eae3d7 @myell0w fixed minor UI-glitch when status bar was small
authored
16 // -------------------------------
91c329e @myell0w added credits
authored
17 // http://stackoverflow.com/questions/2833724/adding-view-on-statusbar-in-iphone
1ccb904 @myell0w Updated Credits
authored
18 // http://www.cocoabyss.com/uikit/custom-status-bar-ios/
19 // @reederapp for inspiration
6eae3d7 @myell0w fixed minor UI-glitch when status bar was small
authored
20 // -------------------------------
91c329e @myell0w added credits
authored
21
b645dd5 @myell0w Initial Commit: Black or Gray Status Bar Overlay that can change it's…
authored
22 #import <Foundation/Foundation.h>
23
237c446 @myell0w Added delegate protocol MTStatusBarOverlayDelegate
authored
24
25 //===========================================================
26 #pragma mark -
27 #pragma mark Definitions and Types
28 //===========================================================
29
526aed2 @myell0w Changed MTStatusBarOverlay to be a Singleton, minor changes and comme…
authored
30 // Animation that happens, when the user touches the status bar overlay
56204e6 @myell0w added different animation modes
authored
31 typedef enum MTStatusBarOverlayAnimation {
35ec5ab @myell0w New feature: Basic functionality to save/restore state
authored
32 MTStatusBarOverlayAnimationNone, // nothing happens
33 MTStatusBarOverlayAnimationShrink, // the status bar shrinks to the right side and only shows the activity indicator
34 MTStatusBarOverlayAnimationFallDown // the status bar falls down and displays more information
56204e6 @myell0w added different animation modes
authored
35 } MTStatusBarOverlayAnimation;
36
b645dd5 @myell0w Initial Commit: Black or Gray Status Bar Overlay that can change it's…
authored
37
b0713be @myell0w New feature: 3 different detailViewModes, set a text with new propert…
authored
38 // Mode of the detail view
39 typedef enum MTDetailViewMode {
40 MTDetailViewModeHistory, // History of messages is recorded and displayed in detailView
41 MTDetailViewModeDetailText, // a text can be displayed easily
42 MTDetailViewModeCustom // the detailView can be customized in the way the developer wants
43 } MTDetailViewMode;
44
237c446 @myell0w Added delegate protocol MTStatusBarOverlayDelegate
authored
45 // indicates the type of a message
46 typedef enum MTMessageType {
47 MTMessageTypeActivity, // shows actvity indicator
48 MTMessageTypeFinish, // shows checkmark
49 MTMessageTypeError // shows error-mark
50 } MTMessageType;
51
52
35ec5ab @myell0w New feature: Basic functionality to save/restore state
authored
53 // keys used in the dictionary-representation of a status message
237c446 @myell0w Added delegate protocol MTStatusBarOverlayDelegate
authored
54 #define kMTStatusBarOverlayMessageKey @"MessageText"
55 #define kMTStatusBarOverlayMessageTypeKey @"MessageType"
56 #define kMTStatusBarOverlayDurationKey @"MessageDuration"
57 #define kMTStatusBarOverlayAnimationKey @"MessageAnimation"
85f77a5 @myell0w Bugfix: Immediate messages won't get removed from queue, when a new i…
authored
58 #define kMTStatusBarOverlayImmediateKey @"MessageImmediate"
237c446 @myell0w Added delegate protocol MTStatusBarOverlayDelegate
authored
59
35ec5ab @myell0w New feature: Basic functionality to save/restore state
authored
60 // keys used for saving state to NSUserDefaults
61 #define kMTStatusBarOverlayStateShrinked @"kMTStatusBarOverlayStateShrinked"
62
63
64 // forward-declaration of delegate-protocol
65 @protocol MTStatusBarOverlayDelegate;
66
67
237c446 @myell0w Added delegate protocol MTStatusBarOverlayDelegate
authored
68 //===========================================================
69 #pragma mark -
70 #pragma mark MTStatusBarOverlay Interface
71 //===========================================================
72
bbd9539 @myell0w Converted to ARC
authored
73 /**
74 This class provides an overlay over the iOS Status Bar that can display information
75 and perform an animation when you touch it:
76
77 it can either shrink and only overlap the battery-icon (like in Reeder) or it can display
78 a detail-view that shows additional information. You can show a history of all the previous
79 messages for free by setting historyEnabled to YES
80 */
81 @interface MTStatusBarOverlay : UIWindow <UITableViewDataSource>
237c446 @myell0w Added delegate protocol MTStatusBarOverlayDelegate
authored
82
a70776b @myell0w Simplified usage: now every message gets queued
authored
83 // the view that holds all the components of the overlay (except for the detailView)
bbd9539 @myell0w Converted to ARC
authored
84 @property (nonatomic, strong) UIView *backgroundView;
a70776b @myell0w Simplified usage: now every message gets queued
authored
85 // the detailView is shown when animation is set to "FallDown"
bbd9539 @myell0w Converted to ARC
authored
86 @property (nonatomic, strong) UIView *detailView;
f81b04f @myell0w New feature: MTStatusBarOverlay can now show the progress by using al…
authored
87 // the current progress
88 @property (nonatomic, assign) double progress;
a70776b @myell0w Simplified usage: now every message gets queued
authored
89 // the frame of the status bar when animation is set to "Shrink" and it is shrinked
bacc2f4 @myell0w Rotation second step: working on iPhone including Shrink-Mode
authored
90 @property (nonatomic, assign) CGRect smallFrame;
a70776b @myell0w Simplified usage: now every message gets queued
authored
91 // the current active animation
56204e6 @myell0w added different animation modes
authored
92 @property (nonatomic, assign) MTStatusBarOverlayAnimation animation;
a70776b @myell0w Simplified usage: now every message gets queued
authored
93 // the label that holds the finished-indicator (either a checkmark, or a error-sign per default)
bbd9539 @myell0w Converted to ARC
authored
94 @property (nonatomic, strong) UILabel *finishedLabel;
83eb7e2 @myell0w New property hidesActivity: if set to YES, neither activityIndicator …
authored
95 // if this flag is set to YES, neither activityIndicator nor finishedLabel are shown
96 @property (nonatomic, assign) BOOL hidesActivity;
95d6c7b @myell0w Made properties for background-image used in UIStatusBarStyleDefault …
authored
97 // the image used when the Status Bar Style is Default
bbd9539 @myell0w Converted to ARC
authored
98 @property (nonatomic, strong) UIImage *defaultStatusBarImage;
95d6c7b @myell0w Made properties for background-image used in UIStatusBarStyleDefault …
authored
99 // the image used when the Status Bar Style is Default and the Overlay is shrinked
bbd9539 @myell0w Converted to ARC
authored
100 @property (nonatomic, strong) UIImage *defaultStatusBarImageShrinked;
4c5a154 @myell0w Fixed: StatusBar can be shrinked during animation of new text, began …
authored
101 // detect if status bar is currently shrinked
102 @property (nonatomic, readonly, getter=isShrinked) BOOL shrinked;
067111f @myell0w Cleaned up code, removed shadow: was visible in shrinked mode
authored
103 // detect if detailView is currently hidden
104 @property (nonatomic, readonly, getter=isDetailViewHidden) BOOL detailViewHidden;
81d639d @myell0w First version of message-history
authored
105 // all messages that were displayed since the last finish-call
bbd9539 @myell0w Converted to ARC
authored
106 @property (nonatomic, strong, readonly) NSMutableArray *messageHistory;
b0713be @myell0w New feature: 3 different detailViewModes, set a text with new propert…
authored
107 // DEPRECATED: enable/disable history-tracking of messages
a855966 @myell0w Added property to enable/disable history
authored
108 @property (nonatomic, assign, getter=isHistoryEnabled) BOOL historyEnabled;
c0ef3b2 @myell0w Added property to determine last posted message
authored
109 // the last message that was visible
54275d4 @myell0w Expose lastPostedMessage as write-able
authored
110 @property (nonatomic, copy) NSString *lastPostedMessage;
b296913 @myell0w New property: canRemoveImmediateMessageFromQueue determines whether i…
authored
111 // determines if immediate messages in the queue get removed or stay in the queue, when a new immediate message gets posted
112 @property (nonatomic, assign) BOOL canRemoveImmediateMessagesFromQueue;
b0713be @myell0w New feature: 3 different detailViewModes, set a text with new propert…
authored
113 // the mode of the detailView
114 @property (nonatomic, assign) MTDetailViewMode detailViewMode;
115 // the text displayed in the detailView (alternative to history)
116 @property (nonatomic, copy) NSString *detailText;
237c446 @myell0w Added delegate protocol MTStatusBarOverlayDelegate
authored
117 // the delegate of the overlay
bbd9539 @myell0w Converted to ARC
authored
118 @property (nonatomic, unsafe_unretained) id<MTStatusBarOverlayDelegate> delegate;
cefe1b4 @marclefrancois Add the possibility of customizing the textcolor of the labels
marclefrancois authored
119 @property(nonatomic, strong) UIColor *customTextColor;
526aed2 @myell0w Changed MTStatusBarOverlay to be a Singleton, minor changes and comme…
authored
120 //===========================================================
fedddc1 @myell0w added convenience-methods, refactored code, added ability to disable …
authored
121 #pragma mark -
122 #pragma mark Class Methods
526aed2 @myell0w Changed MTStatusBarOverlay to be a Singleton, minor changes and comme…
authored
123 //===========================================================
fedddc1 @myell0w added convenience-methods, refactored code, added ability to disable …
authored
124
a70776b @myell0w Simplified usage: now every message gets queued
authored
125 // Singleton Instance
526aed2 @myell0w Changed MTStatusBarOverlay to be a Singleton, minor changes and comme…
authored
126 + (MTStatusBarOverlay *)sharedInstance;
d71d042 @myell0w Added more singleton-getter (also thread-safe getter) and added a sim…
authored
127 + (MTStatusBarOverlay *)sharedOverlay;
fedddc1 @myell0w added convenience-methods, refactored code, added ability to disable …
authored
128
526aed2 @myell0w Changed MTStatusBarOverlay to be a Singleton, minor changes and comme…
authored
129 //===========================================================
fedddc1 @myell0w added convenience-methods, refactored code, added ability to disable …
authored
130 #pragma mark -
131 #pragma mark Instance Methods
526aed2 @myell0w Changed MTStatusBarOverlay to be a Singleton, minor changes and comme…
authored
132 //===========================================================
fedddc1 @myell0w added convenience-methods, refactored code, added ability to disable …
authored
133
134 // for customizing appearance, automatically disabled userInteractionEnabled on view
b645dd5 @myell0w Initial Commit: Black or Gray Status Bar Overlay that can change it's…
authored
135 - (void)addSubviewToBackgroundView:(UIView *)view;
4d932f1 @coneybeare added [- addSubviewToBackgroundView:atIndex:]
coneybeare authored
136 - (void)addSubviewToBackgroundView:(UIView *)view atIndex:(NSInteger)index;
b645dd5 @myell0w Initial Commit: Black or Gray Status Bar Overlay that can change it's…
authored
137
893eca9 @myell0w It's now easier to re-post a message that got cleared from the queue
authored
138 // Method to re-post a cleared message
139 - (void)postMessageDictionary:(NSDictionary *)messageDictionary;
140
a70776b @myell0w Simplified usage: now every message gets queued
authored
141 // shows an activity indicator and the given message
142 - (void)postMessage:(NSString *)message;
cac4ee1 @benjaminscott Allow posting of a message with an explicit duration.
benjaminscott authored
143 - (void)postMessage:(NSString *)message duration:(NSTimeInterval)duration;
9413d5a @myell0w Added more options for posting messages with a specified duration
authored
144 - (void)postMessage:(NSString *)message duration:(NSTimeInterval)duration animated:(BOOL)animated;
a70776b @myell0w Simplified usage: now every message gets queued
authored
145 - (void)postMessage:(NSString *)message animated:(BOOL)animated;
7b162ab @myell0w Added possibility to show a message immediately
authored
146 // clears the message queue and shows this message instantly
147 - (void)postImmediateMessage:(NSString *)message animated:(BOOL)animated;
893eca9 @myell0w It's now easier to re-post a message that got cleared from the queue
authored
148 - (void)postImmediateMessage:(NSString *)message duration:(NSTimeInterval)duration;
9413d5a @myell0w Added more options for posting messages with a specified duration
authored
149 - (void)postImmediateMessage:(NSString *)message duration:(NSTimeInterval)duration animated:(BOOL)animated;
a70776b @myell0w Simplified usage: now every message gets queued
authored
150
526aed2 @myell0w Changed MTStatusBarOverlay to be a Singleton, minor changes and comme…
authored
151 // shows a checkmark instead of the activity indicator and hides the status bar after the specified duration
a70776b @myell0w Simplified usage: now every message gets queued
authored
152 - (void)postFinishMessage:(NSString *)message duration:(NSTimeInterval)duration;
153 - (void)postFinishMessage:(NSString *)message duration:(NSTimeInterval)duration animated:(BOOL)animated;
7b162ab @myell0w Added possibility to show a message immediately
authored
154 // clears the message queue and shows this message instantly
155 - (void)postImmediateFinishMessage:(NSString *)message duration:(NSTimeInterval)duration animated:(BOOL)animated;
a70776b @myell0w Simplified usage: now every message gets queued
authored
156
fb3568d @myell0w added possibility to finish with error message
authored
157 // shows a error-sign instead of the activity indicator and hides the status bar after the specified duration
a70776b @myell0w Simplified usage: now every message gets queued
authored
158 - (void)postErrorMessage:(NSString *)message duration:(NSTimeInterval)duration;
159 - (void)postErrorMessage:(NSString *)message duration:(NSTimeInterval)duration animated:(BOOL)animated;
7b162ab @myell0w Added possibility to show a message immediately
authored
160 // clears the message queue and shows this message instantly
161 - (void)postImmediateErrorMessage:(NSString *)message duration:(NSTimeInterval)duration animated:(BOOL)animated;
a70776b @myell0w Simplified usage: now every message gets queued
authored
162
d2010ff @myell0w Added method to hide the status bar overlay temporary without resetti…
authored
163 // hides the status bar overlay and resets it
a70776b @myell0w Simplified usage: now every message gets queued
authored
164 - (void)hide;
d2010ff @myell0w Added method to hide the status bar overlay temporary without resetti…
authored
165 // hides the status bar overlay but doesn't reset it's values
166 // this is useful if e.g. you have a screen where you don't have
167 // a status bar, but the other screens have one
168 // then you can hide it temporary and show it again afterwards
169 - (void)hideTemporary;
170 // this shows the status bar overlay, if there is text to show
171 - (void)show;
b645dd5 @myell0w Initial Commit: Black or Gray Status Bar Overlay that can change it's…
authored
172
35ec5ab @myell0w New feature: Basic functionality to save/restore state
authored
173 // saves the state in NSUserDefaults and synchronizes them
174 - (void)saveState;
175 - (void)saveStateSynchronized:(BOOL)synchronizeAtEnd;
176 // restores the state from NSUserDefaults
177 - (void)restoreState;
178
b645dd5 @myell0w Initial Commit: Black or Gray Status Bar Overlay that can change it's…
authored
179 @end
237c446 @myell0w Added delegate protocol MTStatusBarOverlayDelegate
authored
180
181
182
183 //===========================================================
184 #pragma mark -
185 #pragma mark Delegate Protocol
186 //===========================================================
187
188 @protocol MTStatusBarOverlayDelegate <NSObject>
189 @optional
3e6caf5 @myell0w New delegate call when a gesture is recognized
authored
190 // is called, when a gesture on the overlay is recognized
191 - (void)statusBarOverlayDidRecognizeGesture:(UIGestureRecognizer *)gestureRecognizer;
237c446 @myell0w Added delegate protocol MTStatusBarOverlayDelegate
authored
192 // is called when the status bar overlay gets hidden
193 - (void)statusBarOverlayDidHide;
194 // is called, when the status bar overlay changed it's displayed message from one message to another
195 - (void)statusBarOverlayDidSwitchFromOldMessage:(NSString *)oldMessage toNewMessage:(NSString *)newMessage;
196 // is called when an immediate message gets posted and therefore messages in the queue get lost
197 // it tells the delegate the lost messages and the delegate can then enqueue the messages again
198 - (void)statusBarOverlayDidClearMessageQueue:(NSArray *)messageQueue;
199 @end
Something went wrong with that request. Please try again.