源码分享站 - 分享有用的

MTStatusBarOverlay 展示 MTStatusBarOverlay.h源代码

返回 下载MTStatusBarOverlay: 单独下载MTStatusBarOverlay.h源代码 - 下载整个MTStatusBarOverlay源代码 - 类型:.h文件
  1. //
  2. //  MTStatusBarOverlay.m
  3. //
  4. //  Created by Matthias Tretter on 27.09.10.
  5. //  Copyright (c) 2009-2011  Matthias Tretter, @myell0w. All rights reserved.
  6. //
  7. // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
  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.
  11. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  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.
  14. //
  15. // Credits go to:
  16. // -------------------------------
  17. // http://stackoverflow.com/questions/2833724/adding-view-on-statusbar-in-iphone
  18. // http://www.cocoabyss.com/uikit/custom-status-bar-ios/
  19. // @reederapp for inspiration
  20. // -------------------------------
  21.  
  22. #import <Foundation/Foundation.h>
  23.  
  24.  
  25. //===========================================================
  26. #pragma mark -
  27. #pragma mark Definitions and Types
  28. //===========================================================
  29.  
  30. // Animation that happens, when the user touches the status bar overlay
  31. typedef enum MTStatusBarOverlayAnimation {
  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
  35. } MTStatusBarOverlayAnimation;
  36.  
  37.  
  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.  
  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.  
  53. // keys used in the dictionary-representation of a status message
  54. #define kMTStatusBarOverlayMessageKey                   @"MessageText"
  55. #define kMTStatusBarOverlayMessageTypeKey               @"MessageType"
  56. #define kMTStatusBarOverlayDurationKey                  @"MessageDuration"
  57. #define kMTStatusBarOverlayAnimationKey                 @"MessageAnimation"
  58. #define kMTStatusBarOverlayImmediateKey                 @"MessageImmediate"
  59.  
  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.  
  68. //===========================================================
  69. #pragma mark -
  70. #pragma mark MTStatusBarOverlay Interface
  71. //===========================================================
  72.  
  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>
  82.  
  83. // the view that holds all the components of the overlay (except for the detailView)
  84. @property (nonatomic, strong) UIView *backgroundView;
  85. // the detailView is shown when animation is set to "FallDown"
  86. @property (nonatomic, strong) UIView *detailView;
  87. // the current progress
  88. @property (nonatomic, assign) double progress;
  89. // the frame of the status bar when animation is set to "Shrink" and it is shrinked
  90. @property (nonatomic, assign) CGRect smallFrame;
  91. // the current active animation
  92. @property (nonatomic, assign) MTStatusBarOverlayAnimation animation;
  93. // the label that holds the finished-indicator (either a checkmark, or a error-sign per default)
  94. @property (nonatomic, strong) UILabel *finishedLabel;
  95. // if this flag is set to YES, neither activityIndicator nor finishedLabel are shown
  96. @property (nonatomic, assign) BOOL hidesActivity;
  97. // the image used when the Status Bar Style is Default
  98. @property (nonatomic, strong) UIImage *defaultStatusBarImage;
  99. // the image used when the Status Bar Style is Default and the Overlay is shrinked
  100. @property (nonatomic, strong) UIImage *defaultStatusBarImageShrinked;
  101. // detect if status bar is currently shrinked
  102. @property (nonatomic, readonly, getter=isShrinked) BOOL shrinked;
  103. // detect if detailView is currently hidden
  104. @property (nonatomic, readonly, getter=isDetailViewHidden) BOOL detailViewHidden;
  105. // all messages that were displayed since the last finish-call
  106. @property (nonatomic, strong, readonly) NSMutableArray *messageHistory;
  107. // DEPRECATED: enable/disable history-tracking of messages
  108. @property (nonatomic, assign, getter=isHistoryEnabled) BOOL historyEnabled;
  109. // the last message that was visible
  110. @property (nonatomic, copy) NSString *lastPostedMessage;
  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;
  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;
  117. // the delegate of the overlay
  118. @property (nonatomic, unsafe_unretained) id<MTStatusBarOverlayDelegate> delegate;
  119. @property(nonatomic, strong) UIColor *customTextColor;
  120. //===========================================================
  121. #pragma mark -
  122. #pragma mark Class Methods
  123. //===========================================================
  124.  
  125. // Singleton Instance
  126. + (MTStatusBarOverlay *)sharedInstance;
  127. + (MTStatusBarOverlay *)sharedOverlay;
  128.  
  129. //===========================================================
  130. #pragma mark -
  131. #pragma mark Instance Methods
  132. //===========================================================
  133.  
  134. // for customizing appearance, automatically disabled userInteractionEnabled on view
  135. - (void)addSubviewToBackgroundView:(UIView *)view;
  136. - (void)addSubviewToBackgroundView:(UIView *)view atIndex:(NSInteger)index;
  137.  
  138. // Method to re-post a cleared message
  139. - (void)postMessageDictionary:(NSDictionary *)messageDictionary;
  140.  
  141. // shows an activity indicator and the given message
  142. - (void)postMessage:(NSString *)message;
  143. - (void)postMessage:(NSString *)message duration:(NSTimeInterval)duration;
  144. - (void)postMessage:(NSString *)message duration:(NSTimeInterval)duration animated:(BOOL)animated;
  145. - (void)postMessage:(NSString *)message animated:(BOOL)animated;
  146. // clears the message queue and shows this message instantly
  147. - (void)postImmediateMessage:(NSString *)message animated:(BOOL)animated;
  148. - (void)postImmediateMessage:(NSString *)message duration:(NSTimeInterval)duration;
  149. - (void)postImmediateMessage:(NSString *)message duration:(NSTimeInterval)duration animated:(BOOL)animated;
  150.  
  151. // shows a checkmark instead of the activity indicator and hides the status bar after the specified duration
  152. - (void)postFinishMessage:(NSString *)message duration:(NSTimeInterval)duration;
  153. - (void)postFinishMessage:(NSString *)message duration:(NSTimeInterval)duration animated:(BOOL)animated;
  154. // clears the message queue and shows this message instantly
  155. - (void)postImmediateFinishMessage:(NSString *)message duration:(NSTimeInterval)duration animated:(BOOL)animated;
  156.  
  157. // shows a error-sign instead of the activity indicator and hides the status bar after the specified duration
  158. - (void)postErrorMessage:(NSString *)message duration:(NSTimeInterval)duration;
  159. - (void)postErrorMessage:(NSString *)message duration:(NSTimeInterval)duration animated:(BOOL)animated;
  160. // clears the message queue and shows this message instantly
  161. - (void)postImmediateErrorMessage:(NSString *)message duration:(NSTimeInterval)duration animated:(BOOL)animated;
  162.  
  163. // hides the status bar overlay and resets it
  164. - (void)hide;
  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;
  172.  
  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.  
  179. @end
  180.  
  181.  
  182.  
  183. //===========================================================
  184. #pragma mark -
  185. #pragma mark Delegate Protocol
  186. //===========================================================
  187.  
  188. @protocol MTStatusBarOverlayDelegate <NSObject>
  189. @optional
  190. // is called, when a gesture on the overlay is recognized
  191. - (void)statusBarOverlayDidRecognizeGesture:(UIGestureRecognizer *)gestureRecognizer;
  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
  200.  
单独下载 单独下载MTStatusBarOverlay.h源码 - 下载整个MTStatusBarOverlay源程序
相关源码/软件:
blueprint - 反向工程服务器配置 http://devstructure.com/ 2017-05-12
PullToRefresh - A simple iPhone TableViewController for adding pul... 2017-05-12
mrjob - 在 Hadoop 或亚马逊网络服务上运行 MapReduce 作业 http... 2017-05-11
wax - 阿里巴巴现在正在维护蜡 https://github.com/alibaba... 2017-05-11
ledisdb - 一种高性能 NoSQL 动力去 http://ledisdb.com 2017-05-11
www.html5rocks.com - .......a 争创一流资源为 web 开发人员 2017-05-12
hologram - 降价基于文件系统的风格指南。 http://trulia.github.io... 2017-05-12
isso - Disqus 替代 https://posativ.org/isso/ 2017-05-12
python3-cookbook - 《Python Cookbook》 3rd Edition Translatio 2017-05-12
TSA-Travel-Sentry-master-keys - TSA 主密钥的 3D 再现 2017-05-12
CRYENGINE - CRYENGINE 是由 Crytek 创建一个功能强大的实时游戏开发平台。 ... 2017-06-11
postal - 2017-06-11
reactide - Reactide 是反应 web 应用程序开发的第一个专用的 IDE。http://reactide... 2017-06-11
rkt - rkt 是为 Linux 的 pod 本机容器引擎。它是可组合、 安全和建筑标准。 2017-06-11
uWebSockets - 小小的 Websocket https://forest.webvrexpe... 2017-06-11
realworld - 真实的世界-动力反应、 角、 节点,Django,和更多的模范 fullstack Medium.c... 2017-06-11
goreplay - GoReplay 是用于捕获和重播活 HTTP 交通到测试环境以不断地测试您的系统与实际数据的开源工... 2017-06-10
pyenv - 简单的 Python 版本管理 2017-06-10
redux-saga - Redux 应用程序替代副作用模型 https://redux-saga.g... 2017-06-10
angular-starter - 2017-06-10

 返回顶部