24 Commits

Author SHA1 Message Date
Matej Bukovinski 1761e41355 Version bump to 0.7. 2013-06-25 14:22:30 +02:00
Matej Bukovinski 83c7ce6aae Migrated the change log to the wiki. 2013-06-25 14:29:29 +03:00
Matej Bukovinski a25be7e1e8 Added a few pragma declarations to MBBarProgressView. 2013-06-25 13:17:44 +02:00
Matej Bukovinski 2f11106a92 Migrated some property overrides to KVO on MBRoundProgressView. 2013-06-25 13:16:54 +02:00
Matej Bukovinski 64a3f8ac8b Fixed the determinate demo. 2013-06-25 13:16:02 +02:00
Matej Bukovinski 6c4bd53249 Cleanup of the new horizontal bar functionality.
- added class prefix to the bar class, to minimize the chance for namespace collisions
 - exposed and documented the MBBarProgressView interface
 - removed some non-crucial methods to simplify the API
 - adjusted the default values for some attributers
 - cleaned up the code style, so it matches the rest of the class
 - added proper ARC macros
 - using KVO instead of accessor overrides for UI update triggering
2013-06-25 13:13:12 +02:00
Matej Bukovinski d3c6f30b00 Extended the demo with an example for the new horizontal bar mode. 2013-06-25 12:41:52 +02:00
Matej Bukovinski 8a84e57ede Merge pull request #142 from markd2/master
Quiet warning in non-ARC mode
2013-06-25 03:27:25 -07:00
markd2 427a8ababa Added super dealloc for FlatProgressView, no-ARC mode 2013-06-21 10:02:45 -04:00
Jonathan George c45743cc20 Merge pull request #139 from jjxtra/master
Add horizontal progress bar
2013-06-19 13:30:47 -07:00
Jeff Johnson e726947f61 Another ARC tweak 2013-05-20 15:53:25 -06:00
Jeff Johnson c84bea7b7b Add in horizontal progress bar 2013-05-20 15:51:39 -06:00
Matej Bukovinski c24d6e7fcd Merge pull request #137 from cbeninati/patch-1
fixed typos "than" to "then"
2013-05-13 22:11:51 -07:00
cbeninati f53fbdc0af fixed typos "than" to "then" 2013-05-13 17:53:49 -05:00
Matej Bukovinski aa9ecd55da Merge pull request #135 from matej/master
Travis integration.
2013-04-28 23:43:15 -07:00
Matej Bukovinski 980ca2a73f Fixed readme typo. 2013-04-28 21:38:55 +03:00
Matej Bukovinski 7f1f919937 Added build status to the readme. 2013-04-28 21:36:36 +03:00
Matej Bukovinski 7d8d0ddba4 Published schemes. 2013-04-28 20:32:05 +02:00
Matej Bukovinski a082c2f63d Added .travis.yml. 2013-04-28 20:20:48 +02:00
Matej Bukovinski 19f91d283b Slight macro formatting cleanup. 2013-03-18 10:25:56 +01:00
Matej Bukovinski 50f23054b1 Merge pull request #125 from mrackwitz/master
Improved subclassing
2013-03-18 02:23:20 -07:00
Marius Rackwitz ed8f872664 Added macro for compilers which doesn't support instancetype 2013-03-17 00:07:27 +01:00
Matej Bukovinski 2065aa5c0b A few documentation fixes. 2013-03-13 12:07:00 +01:00
Marius Rackwitz 973aa1b268 Replaced fix class type through instancetype and used self in static methods instead of fixed class reference to enable improved subclassing 2013-03-12 18:00:01 +01:00
10 changed files with 450 additions and 143 deletions
+1
View File
@@ -0,0 +1 @@
language: objective-c
+1
View File
@@ -21,6 +21,7 @@
- (IBAction)showWithDetailsLabel:(id)sender;
- (IBAction)showWithLabelDeterminate:(id)sender;
- (IBAction)showWIthLabelAnnularDeterminate:(id)sender;
- (IBAction)showWithLabelDeterminateHorizontalBar:(id)sender;
- (IBAction)showWithCustomView:(id)sender;
- (IBAction)showWithLabelMixed:(id)sender;
- (IBAction)showUsingBlocks:(id)sender;
+14
View File
@@ -103,6 +103,20 @@
[HUD showWhileExecuting:@selector(myProgressTask) onTarget:self withObject:nil animated:YES];
}
- (IBAction)showWithLabelDeterminateHorizontalBar:(id)sender {
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
// Set determinate bar mode
HUD.mode = MBProgressHUDModeDeterminateHorizontalBar;
HUD.delegate = self;
// myProgressTask uses the HUD instance to update progress
[HUD showWhileExecuting:@selector(myProgressTask) onTarget:self withObject:nil animated:YES];
}
- (IBAction)showWithCustomView:(id)sender {
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0460"
version = "1.8">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "HudDemo.app"
BlueprintName = "HudDemo"
ReferencedContainer = "container:HudDemo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
displayScaleIsEnabled = "NO"
displayScale = "1.00"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "HudDemo.app"
BlueprintName = "HudDemo"
ReferencedContainer = "container:HudDemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
displayScaleIsEnabled = "NO"
displayScale = "1.00"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "HudDemo.app"
BlueprintName = "HudDemo"
ReferencedContainer = "container:HudDemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
+74 -26
View File
@@ -2,13 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">528</int>
<string key="IBDocument.SystemVersion">12C54</string>
<string key="IBDocument.InterfaceBuilderVersion">2840</string>
<string key="IBDocument.AppKitVersion">1187.34</string>
<string key="IBDocument.HIToolboxVersion">625.00</string>
<string key="IBDocument.SystemVersion">12E55</string>
<string key="IBDocument.InterfaceBuilderVersion">3084</string>
<string key="IBDocument.AppKitVersion">1187.39</string>
<string key="IBDocument.HIToolboxVersion">626.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">1926</string>
<string key="NS.object.0">2083</string>
</object>
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -161,7 +161,7 @@
<string key="NSFrame">{{20, 212}, {280, 40}}</string>
<reference key="NSSuperview" ref="821963304"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="424785"/>
<reference key="NSNextKeyView" ref="760960186"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
@@ -178,10 +178,33 @@
<reference key="IBUIFontDescription" ref="931117317"/>
<reference key="IBUIFont" ref="432819284"/>
</object>
<object class="IBUIButton" id="760960186">
<reference key="NSNextResponder" ref="821963304"/>
<int key="NSvFlags">290</int>
<string key="NSFrame">{{20, 257}, {280, 44}}</string>
<reference key="NSSuperview" ref="821963304"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="424785"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">3</int>
<int key="IBUIButtonType">1</int>
<string key="IBUINormalTitle">Bar determinate mode</string>
<reference key="IBUIHighlightedTitleColor" ref="434568641"/>
<object class="NSColor" key="IBUINormalTitleColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA</bytes>
</object>
<reference key="IBUINormalTitleShadowColor" ref="612289531"/>
<reference key="IBUIFontDescription" ref="931117317"/>
<reference key="IBUIFont" ref="432819284"/>
</object>
<object class="IBUIButton" id="319652209">
<reference key="NSNextResponder" ref="821963304"/>
<int key="NSvFlags">290</int>
<string key="NSFrame">{{20, 308}, {280, 40}}</string>
<string key="NSFrame">{{20, 354}, {280, 40}}</string>
<reference key="NSSuperview" ref="821963304"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="302056160"/>
@@ -204,7 +227,7 @@
<object class="IBUIButton" id="302056160">
<reference key="NSNextResponder" ref="821963304"/>
<int key="NSvFlags">290</int>
<string key="NSFrame">{{20, 354}, {280, 44}}</string>
<string key="NSFrame">{{20, 400}, {280, 44}}</string>
<reference key="NSSuperview" ref="821963304"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="304407605"/>
@@ -227,7 +250,7 @@
<object class="IBUIButton" id="304407605">
<reference key="NSNextResponder" ref="821963304"/>
<int key="NSvFlags">290</int>
<string key="NSFrame">{{20, 404}, {280, 40}}</string>
<string key="NSFrame">{{20, 450}, {280, 40}}</string>
<reference key="NSSuperview" ref="821963304"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="295510578"/>
@@ -250,7 +273,7 @@
<object class="IBUIButton" id="295510578">
<reference key="NSNextResponder" ref="821963304"/>
<int key="NSvFlags">290</int>
<string key="NSFrame">{{20, 452}, {280, 40}}</string>
<string key="NSFrame">{{20, 498}, {280, 40}}</string>
<reference key="NSSuperview" ref="821963304"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="8005370"/>
@@ -273,7 +296,7 @@
<object class="IBUIButton" id="424785">
<reference key="NSNextResponder" ref="821963304"/>
<int key="NSvFlags">290</int>
<string key="NSFrame">{{20, 260}, {280, 40}}</string>
<string key="NSFrame">{{20, 306}, {280, 40}}</string>
<reference key="NSSuperview" ref="821963304"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="319652209"/>
@@ -296,7 +319,7 @@
<object class="IBUIButton" id="8005370">
<reference key="NSNextResponder" ref="821963304"/>
<int key="NSvFlags">290</int>
<string key="NSFrame">{{20, 499}, {280, 40}}</string>
<string key="NSFrame">{{20, 545}, {280, 40}}</string>
<reference key="NSSuperview" ref="821963304"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="686140023"/>
@@ -319,7 +342,7 @@
<object class="IBUIButton" id="686140023">
<reference key="NSNextResponder" ref="821963304"/>
<int key="NSvFlags">290</int>
<string key="NSFrame">{{20, 547}, {280, 40}}</string>
<string key="NSFrame">{{20, 593}, {280, 40}}</string>
<reference key="NSSuperview" ref="821963304"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="952034185"/>
@@ -342,9 +365,10 @@
<object class="IBUIButton" id="952034185">
<reference key="NSNextResponder" ref="821963304"/>
<int key="NSvFlags">290</int>
<string key="NSFrame">{{20, 595}, {280, 37}}</string>
<string key="NSFrame">{{20, 641}, {280, 37}}</string>
<reference key="NSSuperview" ref="821963304"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
@@ -371,7 +395,7 @@
<reference key="IBUIFont" ref="432819284"/>
</object>
</object>
<string key="NSFrameSize">{320, 649}</string>
<string key="NSFrameSize">{320, 697}</string>
<reference key="NSSuperview" ref="560298147"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="960472997"/>
@@ -384,7 +408,7 @@
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
</object>
<string key="NSFrameSize">{320, 649}</string>
<string key="NSFrameSize">{320, 697}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="821963304"/>
@@ -501,7 +525,7 @@
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">108</int>
<int key="connectionID">120</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
@@ -521,6 +545,15 @@
</object>
<int key="connectionID">116</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">showWithLabelDeterminateHorizontalBar:</string>
<reference key="source" ref="760960186"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">121</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -560,15 +593,16 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="244375631"/>
<reference ref="322519489"/>
<reference ref="319652209"/>
<reference ref="424785"/>
<reference ref="304407605"/>
<reference ref="302056160"/>
<reference ref="626654324"/>
<reference ref="295510578"/>
<reference ref="960472997"/>
<reference ref="8005370"/>
<reference ref="706142914"/>
<reference ref="760960186"/>
<reference ref="319652209"/>
<reference ref="302056160"/>
<reference ref="304407605"/>
<reference ref="295510578"/>
<reference ref="424785"/>
<reference ref="8005370"/>
<reference ref="686140023"/>
<reference ref="952034185"/>
</object>
@@ -639,6 +673,11 @@
<reference key="object" ref="952034185"/>
<reference key="parent" ref="821963304"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">117</int>
<reference key="object" ref="760960186"/>
<reference key="parent" ref="821963304"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -653,6 +692,7 @@
<string>106.IBPluginDependency</string>
<string>111.IBPluginDependency</string>
<string>115.IBPluginDependency</string>
<string>117.IBPluginDependency</string>
<string>16.IBPluginDependency</string>
<string>20.IBPluginDependency</string>
<string>43.IBPluginDependency</string>
@@ -686,6 +726,7 @@
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -700,7 +741,7 @@
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">116</int>
<int key="maxID">121</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -724,6 +765,7 @@
<string>showWithGradient:</string>
<string>showWithLabel:</string>
<string>showWithLabelDeterminate:</string>
<string>showWithLabelDeterminateHorizontalBar:</string>
<string>showWithLabelMixed:</string>
</object>
<object class="NSArray" key="dict.values">
@@ -741,6 +783,7 @@
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
@@ -759,6 +802,7 @@
<string>showWithGradient:</string>
<string>showWithLabel:</string>
<string>showWithLabelDeterminate:</string>
<string>showWithLabelDeterminateHorizontalBar:</string>
<string>showWithLabelMixed:</string>
</object>
<object class="NSArray" key="dict.values">
@@ -811,6 +855,10 @@
<string key="name">showWithLabelDeterminate:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">showWithLabelDeterminateHorizontalBar:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">showWithLabelMixed:</string>
<string key="candidateClassName">id</string>
@@ -832,7 +880,7 @@
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
<real value="1536" key="NS.object.0"/>
<real value="1552" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
@@ -840,6 +888,6 @@
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<string key="IBCocoaTouchPluginVersion">1926</string>
<string key="IBCocoaTouchPluginVersion">2083</string>
</data>
</archive>
+48 -7
View File
@@ -1,6 +1,6 @@
//
// MBProgressHUD.h
// Version 0.6
// Version 0.7
// Created by Matej Bukovinski on 2.4.09.
//
@@ -38,6 +38,8 @@ typedef enum {
MBProgressHUDModeIndeterminate,
/** Progress is shown using a round, pie-chart like, progress view. */
MBProgressHUDModeDeterminate,
/** Progress is shown using a horizontal progress bar */
MBProgressHUDModeDeterminateHorizontalBar,
/** Progress is shown using a ring-shaped progress view. */
MBProgressHUDModeAnnularDeterminate,
/** Shows a custom view */
@@ -56,6 +58,14 @@ typedef enum {
} MBProgressHUDAnimation;
#ifndef MB_INSTANCETYPE
#if __has_feature(objc_instancetype)
#define MB_INSTANCETYPE instancetype
#else
#define MB_INSTANCETYPE id
#endif
#endif
#ifndef MB_STRONG
#if __has_feature(objc_arc)
#define MB_STRONG strong
@@ -111,7 +121,7 @@ typedef void (^MBProgressHUDCompletionBlock)();
* @see hideHUDForView:animated:
* @see animationType
*/
+ (MBProgressHUD *)showHUDAddedTo:(UIView *)view animated:(BOOL)animated;
+ (MB_INSTANCETYPE)showHUDAddedTo:(UIView *)view animated:(BOOL)animated;
/**
* Finds the top-most HUD subview and hides it. The counterpart to this method is showHUDAddedTo:animated:.
@@ -134,7 +144,7 @@ typedef void (^MBProgressHUDCompletionBlock)();
* animations while disappearing.
* @return the number of HUDs found and removed.
*
* @see hideAllHUDForView:animated:
* @see hideHUDForView:animated:
* @see animationType
*/
+ (NSUInteger)hideAllHUDsForView:(UIView *)view animated:(BOOL)animated;
@@ -145,7 +155,7 @@ typedef void (^MBProgressHUDCompletionBlock)();
* @param view The view that is going to be searched.
* @return A reference to the last HUD subview discovered.
*/
+ (MBProgressHUD *)HUDForView:(UIView *)view;
+ (MB_INSTANCETYPE)HUDForView:(UIView *)view;
/**
* Finds all HUD subviews and returns them.
@@ -227,21 +237,21 @@ typedef void (^MBProgressHUDCompletionBlock)();
/**
* Shows the HUD while a block is executing on a background queue, then hides the HUD.
*
* @see showAnimated:whileExecutingBlock:onQueue:completion:
* @see showAnimated:whileExecutingBlock:onQueue:completionBlock:
*/
- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block;
/**
* Shows the HUD while a block is executing on a background queue, then hides the HUD.
*
* @see showAnimated:whileExecutingBlock:onQueue:completion:
* @see showAnimated:whileExecutingBlock:onQueue:completionBlock:
*/
- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block completionBlock:(MBProgressHUDCompletionBlock)completion;
/**
* Shows the HUD while a block is executing on the specified dispatch queue, then hides the HUD.
*
* @see showAnimated:whileExecutingBlock:onQueue:completion:
* @see showAnimated:whileExecutingBlock:onQueue:completionBlock:
*/
- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue;
@@ -441,3 +451,34 @@ typedef void (^MBProgressHUDCompletionBlock)();
@property (nonatomic, assign, getter = isAnnular) BOOL annular;
@end
/**
* A flat bar progress view.
*/
@interface MBBarProgressView : UIView
/**
* Progress (0.0 to 1.0)
*/
@property (nonatomic, assign) float progress;
/**
* Bar border line color.
* Defaults to white [UIColor whiteColor].
*/
@property (nonatomic, MB_STRONG) UIColor *lineColor;
/**
* Bar background color.
* Defaults to clear [UIColor clearColor];
*/
@property (nonatomic, MB_STRONG) UIColor *progressRemainingColor;
/**
* Bar progress color.
* Defaults to white [UIColor whiteColor].
*/
@property (nonatomic, MB_STRONG) UIColor *progressColor;
@end
+167 -40
View File
@@ -1,6 +1,6 @@
//
// MBProgressHUD.m
// Version 0.6
// Version 0.7
// Created by Matej Bukovinski on 2.4.09.
//
@@ -104,15 +104,15 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
#pragma mark - Class methods
+ (MBProgressHUD *)showHUDAddedTo:(UIView *)view animated:(BOOL)animated {
MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:view];
+ (MB_INSTANCETYPE)showHUDAddedTo:(UIView *)view animated:(BOOL)animated {
MBProgressHUD *hud = [[self alloc] initWithView:view];
[view addSubview:hud];
[hud show:animated];
return MB_AUTORELEASE(hud);
}
+ (BOOL)hideHUDForView:(UIView *)view animated:(BOOL)animated {
MBProgressHUD *hud = [MBProgressHUD HUDForView:view];
MBProgressHUD *hud = [self HUDForView:view];
if (hud != nil) {
hud.removeFromSuperViewOnHide = YES;
[hud hide:animated];
@@ -122,7 +122,7 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
}
+ (NSUInteger)hideAllHUDsForView:(UIView *)view animated:(BOOL)animated {
NSArray *huds = [self allHUDsForView:view];
NSArray *huds = [MBProgressHUD allHUDsForView:view];
for (MBProgressHUD *hud in huds) {
hud.removeFromSuperViewOnHide = YES;
[hud hide:animated];
@@ -130,11 +130,10 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
return [huds count];
}
+ (MBProgressHUD *)HUDForView:(UIView *)view {
Class hudClass = [MBProgressHUD class];
+ (MB_INSTANCETYPE)HUDForView:(UIView *)view {
NSEnumerator *subviewsEnum = [view.subviews reverseObjectEnumerator];
for (UIView *subview in subviewsEnum) {
if ([subview isKindOfClass:hudClass]) {
if ([subview isKindOfClass:self]) {
return (MBProgressHUD *)subview;
}
}
@@ -144,9 +143,8 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
+ (NSArray *)allHUDsForView:(UIView *)view {
NSMutableArray *huds = [NSMutableArray array];
NSArray *subviews = view.subviews;
Class hudClass = [MBProgressHUD class];
for (UIView *aView in subviews) {
if ([aView isKindOfClass:hudClass]) {
if ([aView isKindOfClass:self]) {
[huds addObject:aView];
}
}
@@ -468,6 +466,12 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
[(UIActivityIndicatorView *)indicator startAnimating];
[self addSubview:indicator];
}
else if (mode == MBProgressHUDModeDeterminateHorizontalBar) {
// Update to bar determinate indicator
[indicator removeFromSuperview];
self.indicator = MB_AUTORELEASE([[MBBarProgressView alloc] init]);
[self addSubview:indicator];
}
else if (mode == MBProgressHUDModeDeterminate || mode == MBProgressHUDModeAnnularDeterminate) {
if (!isRoundIndicator) {
// Update to determinante indicator
@@ -734,35 +738,7 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
@end
@implementation MBRoundProgressView {
float _progress;
BOOL _annular;
}
#pragma mark - Properties
@synthesize progressTintColor = _progressTintColor;
@synthesize backgroundTintColor = _backgroundTintColor;
#pragma mark - Accessors
- (float)progress {
return _progress;
}
- (void)setProgress:(float)progress {
_progress = progress;
[self setNeedsDisplay];
}
- (BOOL)isAnnular {
return _annular;
}
- (void)setAnnular:(BOOL)annular {
_annular = annular;
[self setNeedsDisplay];
}
@implementation MBRoundProgressView
#pragma mark - Lifecycle
@@ -857,7 +833,158 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
}
- (NSArray *)observableKeypaths {
return [NSArray arrayWithObjects:@"progressTintColor", @"backgroundTintColor", nil];
return [NSArray arrayWithObjects:@"progressTintColor", @"backgroundTintColor", @"progress", @"annular", nil];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
[self setNeedsDisplay];
}
@end
@implementation MBBarProgressView
#pragma mark - Lifecycle
- (id)init {
return [self initWithFrame:CGRectMake(.0f, .0f, 120.0f, 20.0f)];
}
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
_progress = 0.f;
_lineColor = [UIColor whiteColor];
_progressColor = [UIColor whiteColor];
_progressRemainingColor = [UIColor clearColor];
self.backgroundColor = [UIColor clearColor];
self.opaque = NO;
[self registerForKVO];
}
return self;
}
- (void)dealloc {
[self unregisterFromKVO];
#if !__has_feature(objc_arc)
[_lineColor release];
[_progressColor release];
[_progressRemainingColor release];
[super dealloc];
#endif
}
#pragma mark - Drawing
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
// setup properties
CGContextSetLineWidth(context, 2);
CGContextSetStrokeColorWithColor(context,[_lineColor CGColor]);
CGContextSetFillColorWithColor(context, [_progressRemainingColor CGColor]);
// draw line border
float radius = (rect.size.height / 2) - 2;
CGContextMoveToPoint(context, 2, rect.size.height/2);
CGContextAddArcToPoint(context, 2, 2, radius + 2, 2, radius);
CGContextAddLineToPoint(context, rect.size.width - radius - 2, 2);
CGContextAddArcToPoint(context, rect.size.width - 2, 2, rect.size.width - 2, rect.size.height / 2, radius);
CGContextAddArcToPoint(context, rect.size.width - 2, rect.size.height - 2, rect.size.width - radius - 2, rect.size.height - 2, radius);
CGContextAddLineToPoint(context, radius + 2, rect.size.height - 2);
CGContextAddArcToPoint(context, 2, rect.size.height - 2, 2, rect.size.height/2, radius);
CGContextFillPath(context);
// draw progress background
CGContextMoveToPoint(context, 2, rect.size.height/2);
CGContextAddArcToPoint(context, 2, 2, radius + 2, 2, radius);
CGContextAddLineToPoint(context, rect.size.width - radius - 2, 2);
CGContextAddArcToPoint(context, rect.size.width - 2, 2, rect.size.width - 2, rect.size.height / 2, radius);
CGContextAddArcToPoint(context, rect.size.width - 2, rect.size.height - 2, rect.size.width - radius - 2, rect.size.height - 2, radius);
CGContextAddLineToPoint(context, radius + 2, rect.size.height - 2);
CGContextAddArcToPoint(context, 2, rect.size.height - 2, 2, rect.size.height/2, radius);
CGContextStrokePath(context);
// setup to draw progress color
CGContextSetFillColorWithColor(context, [_progressColor CGColor]);
radius = radius - 2;
float amount = self.progress * rect.size.width;
// if progress is in the middle area
if (amount >= radius + 4 && amount <= (rect.size.width - radius - 4)) {
// top
CGContextMoveToPoint(context, 4, rect.size.height/2);
CGContextAddArcToPoint(context, 4, 4, radius + 4, 4, radius);
CGContextAddLineToPoint(context, amount, 4);
CGContextAddLineToPoint(context, amount, radius + 4);
// bottom
CGContextMoveToPoint(context, 4, rect.size.height/2);
CGContextAddArcToPoint(context, 4, rect.size.height - 4, radius + 4, rect.size.height - 4, radius);
CGContextAddLineToPoint(context, amount, rect.size.height - 4);
CGContextAddLineToPoint(context, amount, radius + 4);
CGContextFillPath(context);
}
// progress is in the right arc
else if (amount > radius + 4) {
float x = amount - (rect.size.width - radius - 4);
// top
CGContextMoveToPoint(context, 4, rect.size.height/2);
CGContextAddArcToPoint(context, 4, 4, radius + 4, 4, radius);
CGContextAddLineToPoint(context, rect.size.width - radius - 4, 4);
float angle = -acos(x/radius);
if (isnan(angle)) angle = 0;
CGContextAddArc(context, rect.size.width - radius - 4, rect.size.height/2, radius, M_PI, angle, 0);
CGContextAddLineToPoint(context, amount, rect.size.height/2);
// bottom
CGContextMoveToPoint(context, 4, rect.size.height/2);
CGContextAddArcToPoint(context, 4, rect.size.height - 4, radius + 4, rect.size.height - 4, radius);
CGContextAddLineToPoint(context, rect.size.width - radius - 4, rect.size.height - 4);
angle = acos(x/radius);
if (isnan(angle)) angle = 0;
CGContextAddArc(context, rect.size.width - radius - 4, rect.size.height/2, radius, -M_PI, angle, 1);
CGContextAddLineToPoint(context, amount, rect.size.height/2);
CGContextFillPath(context);
}
// progress is in the left arc
else if (amount < radius + 4 && amount > 0) {
// top
CGContextMoveToPoint(context, 4, rect.size.height/2);
CGContextAddArcToPoint(context, 4, 4, radius + 4, 4, radius);
CGContextAddLineToPoint(context, radius + 4, rect.size.height/2);
// bottom
CGContextMoveToPoint(context, 4, rect.size.height/2);
CGContextAddArcToPoint(context, 4, rect.size.height - 4, radius + 4, rect.size.height - 4, radius);
CGContextAddLineToPoint(context, radius + 4, rect.size.height/2);
CGContextFillPath(context);
}
}
#pragma mark - KVO
- (void)registerForKVO {
for (NSString *keyPath in [self observableKeypaths]) {
[self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew context:NULL];
}
}
- (void)unregisterFromKVO {
for (NSString *keyPath in [self observableKeypaths]) {
[self removeObserver:self forKeyPath:keyPath];
}
}
- (NSArray *)observableKeypaths {
return [NSArray arrayWithObjects:@"lineColor", @"progressRemainingColor", @"progressColor", @"progress", nil];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "MBProgressHUD"
s.version = "0.6"
s.version = "0.7"
s.summary = "An iOS activity indicator view."
s.description = <<-DESC
MBProgressHUD is an iOS drop-in class that displays a translucent HUD
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0460"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D286A7481518C70F00E13FB8"
BuildableName = "libMBProgressHUD.a"
BlueprintName = "MBProgressHUD"
ReferencedContainer = "container:MBProgressHUD.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
+4 -69
View File
@@ -1,4 +1,4 @@
# MBProgressHUD
# MBProgressHUD [![Build Status](https://travis-ci.org/matej/MBProgressHUD.png)](https://travis-ci.org/matej/MBProgressHUD)
MBProgressHUD is an iOS drop-in class that displays a translucent HUD with an indicator and/or labels while work is being done in a background thread. The HUD is meant as a replacement for the undocumented, private UIKit UIProgressHUD with some additional features.
@@ -35,7 +35,7 @@ You will need LLVM 3.0 or later in order to build MBProgressHUD.
Alternatively you can directly add the `MBProgressHUD.h` and `MBProgressHUD.m` source files to your project.
1. Download the [latest code version](https://github.com/matej/MBProgressHUD/archive/master.zip) or add the repository as a git submodule to your git-tracked project.
2. Open your project in Xcode, than drag and drop `MBProgressHUD.h` and `MBProgressHUD.m` onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project.
2. Open your project in Xcode, then drag and drop `MBProgressHUD.h` and `MBProgressHUD.m` onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project.
3. Include MBProgressHUD wherever you need it with `#import "MBProgressHUD.h"`.
### Static library
@@ -43,7 +43,7 @@ Alternatively you can directly add the `MBProgressHUD.h` and `MBProgressHUD.m` s
You can also add MBProgressHUD as a static library to your project or workspace.
1. Download the [latest code version](https://github.com/matej/MBProgressHUD/downloads) or add the repository as a git submodule to your git-tracked project.
2. Open your project in Xcode, than drag and drop `MBProgressHUD.xcodeproj` onto your project or workspace (use the "Product Navigator view").
2. Open your project in Xcode, then drag and drop `MBProgressHUD.xcodeproj` onto your project or workspace (use the "Product Navigator view").
3. Select your target and go to the Build phases tab. In the Link Binary With Libraries section select the add button. On the sheet find and add `libMBProgressHUD.a`. You might also need to add `MBProgressHUD` to the Target Dependencies list.
4. Include MBProgressHUD wherever you need it with `#import <MBProgressHUD/MBProgressHUD.h>`.
@@ -98,69 +98,4 @@ This code is distributed under the terms and conditions of the [MIT license](LIC
## Change-log
**Version 0.6** @ 13.03.13
- Full cocoapods support.
- Static library integration option.
- Improved blocks support.
- Bezel color.
- Demo app fixes (iOS 6).
- Various bug-fixes and enhancements.
**Version 0.5** @ 22.03.12
- Major source code modernization and cleanup (KVO, layout code, instance vars, etc.).
- New annular determinate mode.
- New text only mode.
- Added a static library project and Xcode 4 workspace.
- Added methods to find and return HUD(s) on a view.
- Various bug fixes.
- Various demo project enhancements (hi-res rescues, new samples).
IMPORTANT: Requires LLVM 3+.
**Version 0.41** @ 03.01.12
- Support for ARC.
**Version 0.4** @ 25.07.10
- Different animation modes. Default set to zoom.
- Class convenience methods (tadelv - http://github.com/tadelv).
- Autorotation when added to a UIWindow (wuf810 - http://github.com/wuf810).
- Extended demo app.
- Several smaller fixes.
**Version 0.33** @ 27.03.10
- Custom view operation mode added.
- Fixed a memory leak.
**Version 0.32** @ 4.01.10
- Added minShowTime, graceTime, xOffset, yOffset.
- Various fixes.
**Version 0.31** @ 8.10.09
- Fix for touch through during the fade-out animation.
**Version 0.3** @ 30.9.09
- Added show: and hide: methods.
- Now using UIViews layoutSubviews to automate layout calls.
- Added some floors to round pixel positions and thereby prevent unsharp views.
- Some additional documentation and code cleanup.
**Version 0.2** @ 21.7.09
- Added determinate progress mode and switching capabilities between determinate and indeterminate modes.
- Various bug-fixes.
**Version 0.11** @ 2.6.09.
- Updated labelText and detailsLabelText properties to support text modifications while the HUD is being shown.
**Version 0.1** @ 2.4.09
- Initial release.
A brief summary of each MBProgressHUD release can be found on the [wiky](https://github.com/matej/MBProgressHUD/wiki/Change-log).