Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Constant values for customView that represent success and error image…

… views.

Signed-off-by: Zachary Waldowski <zwaldowski@gmail.com>
  • Loading branch information...
commit 69e29056e1272359ee2ae6234d127c895a15a6d0 1 parent 45e4c0b
@zwaldowski authored
View
12 HudDemo.xcodeproj/project.pbxproj
@@ -16,6 +16,8 @@
6C44066F14D77C1D0056E9BE /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6C44066E14D77C1D0056E9BE /* CoreGraphics.framework */; };
6C583A3314D8380D00219C4E /* success.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C583A3114D8380D00219C4E /* success.png */; };
6C583A3414D8380D00219C4E /* success@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C583A3214D8380D00219C4E /* success@2x.png */; };
+ 6C583A3D14D85F8C00219C4E /* error.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C583A3B14D85F8C00219C4E /* error.png */; };
+ 6C583A3E14D85F8C00219C4E /* error@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C583A3C14D85F8C00219C4E /* error@2x.png */; };
D22F7D810F85241C00550BB3 /* MBProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = D22F7D800F85241C00550BB3 /* MBProgressHUD.m */; };
D277FDB311FC834200304321 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = D277FDB211FC834200304321 /* Default.png */; };
D277FDB911FC877E00304321 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = D277FDB711FC877E00304321 /* Icon.png */; };
@@ -35,7 +37,9 @@
6C44066E14D77C1D0056E9BE /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
6C583A3114D8380D00219C4E /* success.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = success.png; sourceTree = "<group>"; };
6C583A3214D8380D00219C4E /* success@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "success@2x.png"; sourceTree = "<group>"; };
- 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ 6C583A3B14D85F8C00219C4E /* error.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = error.png; sourceTree = "<group>"; };
+ 6C583A3C14D85F8C00219C4E /* error@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "error@2x.png"; sourceTree = "<group>"; };
+ 8D1107310486CEB800E47090 /* HudDemo-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "HudDemo-Info.plist"; sourceTree = "<group>"; };
D22F7D7F0F85241C00550BB3 /* MBProgressHUD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MBProgressHUD.h; sourceTree = "<group>"; };
D22F7D800F85241C00550BB3 /* MBProgressHUD.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MBProgressHUD.m; sourceTree = "<group>"; };
D277FDB211FC834200304321 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = "<group>"; };
@@ -65,7 +69,7 @@
28D7ACF70DDB3853001CB0EB /* HudDemoViewController.m */,
2899E5210DE3E06400AC0155 /* HudDemoViewController.xib */,
28AD733E0D9D9553002E5188 /* MainWindow.xib */,
- 8D1107310486CEB800E47090 /* Info.plist */,
+ 8D1107310486CEB800E47090 /* HudDemo-Info.plist */,
29B97316FDCFA39411CA2CEA /* main.m */,
6C583A3A14D83BA600219C4E /* Resources */,
);
@@ -119,6 +123,8 @@
children = (
6C583A3114D8380D00219C4E /* success.png */,
6C583A3214D8380D00219C4E /* success@2x.png */,
+ 6C583A3B14D85F8C00219C4E /* error.png */,
+ 6C583A3C14D85F8C00219C4E /* error@2x.png */,
);
path = Images;
sourceTree = "<group>";
@@ -183,6 +189,8 @@
D2A6FD1D13ABC5A200BFE4C9 /* Default@2x.png in Resources */,
6C583A3314D8380D00219C4E /* success.png in Resources */,
6C583A3414D8380D00219C4E /* success@2x.png in Resources */,
+ 6C583A3D14D85F8C00219C4E /* error.png in Resources */,
+ 6C583A3E14D85F8C00219C4E /* error@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
6 HudDemo/HudDemoViewController.m
@@ -88,7 +88,7 @@ - (IBAction)showWithCustomView:(id)sender {
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
- HUD.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"success"]];
+ HUD.customView = MBProgressHUDSuccessImageView;
// Set custom view mode
HUD.mode = MBProgressHUDModeCustomView;
@@ -197,7 +197,7 @@ - (void)myMixedTask {
HUD.mode = MBProgressHUDModeIndeterminate;
HUD.label.text = @"Cleaning up";
sleep(2);
- HUD.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"success"]];
+ HUD.customView = MBProgressHUDSuccessImageView;
HUD.mode = MBProgressHUDModeCustomView;
HUD.label.text = @"Completed";
sleep(2);
@@ -217,7 +217,7 @@ - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
- HUD.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"success"]];
+ HUD.customView = MBProgressHUDSuccessImageView;
HUD.mode = MBProgressHUDModeCustomView;
[HUD hide:YES afterDelay:2];
}
View
1  HudDemo/HudDemoViewController.xib
@@ -221,7 +221,6 @@
<string key="NSFrame">{{20, 318}, {130, 67}}</string>
<reference key="NSSuperview" ref="821963304"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
View
BIN  Images/error.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Images/error@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
6 MBProgressHUD.h
@@ -7,6 +7,12 @@
#import <UIKit/UIKit.h>
+/** When set as the HUD's custom view, the HUD will show a check image. **/
+extern const id MBProgressHUDSuccessImageView;
+
+/** When set as the HUD's custom view, the HUD will show an error image. **/
+extern const id MBProgressHUDErrorImageView;
+
typedef enum {
/** Progress is shown using an UIActivityIndicatorView. This is the default. */
MBProgressHUDModeIndeterminate,
View
13 MBProgressHUD.m
@@ -10,6 +10,9 @@
#pragma mark Constants and Functions
+const id MBProgressHUDSuccessImageView = @"MBProgressHUDSuccessImageView";
+const id MBProgressHUDErrorImageView = @"MBProgressHUDErrorImageView";
+
static const CGFloat padding = 4.0f;
static const CGFloat margin = 18.0f;
static const CGFloat opacity = 0.85f;
@@ -370,8 +373,14 @@ - (void)setMode:(MBProgressHUDMode)newMode {
}
- (void)setCustomView:(UIView *)newCustomView {
- if ([newCustomView isEqual:customView])
- return;
+ if ([newCustomView isKindOfClass:[NSString class]]) {
+ if ([(id)newCustomView isEqualToString:@"MBProgressHUDSuccessImageView"]) {
+ newCustomView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"success"]];
+ } else if ([(id)newCustomView isEqualToString:@"MBProgressHUDSuccessImageView"]) {
+ newCustomView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"error"]];
+ } else
+ return;
+ }
customView = newCustomView;
Please sign in to comment.
Something went wrong with that request. Please try again.