45 Commits

Author SHA1 Message Date
Matej Bukovinski d9886df3ad Version bump. 2014-08-12 10:30:12 +02:00
Matej Bukovinski 7e0bda2f85 Merge branch 'runeb-master' 2014-08-12 10:27:22 +02:00
Matej Bukovinski b8ef4c4e58 Cleaned up activityIndicatorColor support. 2014-08-12 10:27:02 +02:00
Matej Bukovinski 2716a01b99 Merge branch 'master' of https://github.com/runeb/MBProgressHUD into runeb-master 2014-08-12 10:11:23 +02:00
Matej Bukovinski e368a8c243 Merge branch 'master' of github.com:jdg/MBProgressHUD
Conflicts:
	MBProgressHUD.m
2014-08-12 10:08:20 +02:00
Matej Bukovinski 59682eb65e Removed unnecessary method declarations. 2014-08-12 10:04:19 +02:00
Matej Bukovinski 7ed09decad Improved window rotation animation. 2014-08-12 10:04:19 +02:00
Matej Bukovinski 4b403a7d2a Cleaned up notification handling. 2014-08-12 10:04:19 +02:00
Paul Bramsen 0a15804a71 Use the proper notification for status bar did change 2014-08-12 10:04:19 +02:00
Matej Bukovinski 8eb3e881b9 Merge pull request #200 from gmirabito/master
Expose HUD bezel size as read only public property
2014-08-12 10:04:10 +02:00
Matej Bukovinski 4ad3584fee Merge pull request #211 from paulbramsen/master
Use the proper notification for status bar orientation change
2014-08-12 09:17:47 +02:00
Matej Bukovinski 4f8b21759a Freshened up the checkmark example. 2014-08-12 08:37:26 +02:00
Matej Bukovinski 83630b6198 Updated annular mode for iOS 7+. 2014-08-12 07:56:36 +02:00
Matej Bukovinski bd24a291d1 Removing broken yOffset. 2014-08-12 07:36:47 +02:00
Matej Bukovinski 8e56d3e347 Fixed rotation animation on iOS 8. 2014-08-12 07:28:22 +02:00
Matej Bukovinski 5fb0921dab Updated demo appearance. 2014-08-12 07:19:56 +02:00
Matej Bukovinski f0601bd900 Migrated to kCFCoreFoundationVersionNumber_iOS_8_0. 2014-08-12 06:57:03 +02:00
Matej Bukovinski 194c82c86b Clean up code style. 2014-08-12 06:51:46 +02:00
Matej Bukovinski 516554f1f9 Merge pull request #222 from bsuvorov/master
iOS8:  UIWindow rotation transformation is no longer required.
2014-08-12 06:48:23 +02:00
Boris Suvorov 06fdc08431 Because iOS8 window now rotates its subviews, we need
to skip rotation of the HUD when it is being added to the window.
Learn more here: https://devforums.apple.com/message/981103#981103
2014-08-11 18:08:53 -07:00
Matej Bukovinski 9cfed6bc39 Bumped the deployment target for Xcode 6 compatibility. 2014-07-24 09:28:16 +02:00
Paul Bramsen 4194dcf10a Use the proper notification for status bar did change 2014-06-26 16:53:08 -07:00
Matej Bukovinski 2d3561081b Added missing release calls in non-arc mode. Fixes #206 2014-05-28 10:27:15 +02:00
Matej Bukovinski 8800353105 Fixed spacing. 2014-05-28 10:25:04 +02:00
Matej Bukovinski 5918829642 Comment cleanup / fix. #201 2014-05-16 10:59:21 +02:00
Greg Mirabito 69b4f27895 Expose HUD bezel size as read only public property
We have a situation where we want to add a tap gesture recognizer to
the HUD for “tap to cancel” behavior. We want to ignore the tap gesture
if the tap did not occur within the bezel region of the HUD. By
exposing the ‘size’ property, we can determine if the tap location is
within the rectangle of the bezel.

Here is an example of code that processes a tap event that was added to
the HUD

-(void)tapReceived:(UITapGestureRecognizer *)recognizer{
    CGPoint loc = [recognizer locationInView:progress];

    CGFloat w = progress.size.width;
    CGFloat h = progress.size.height;
    CGFloat x = progress.center.x - w/2;
    CGFloat y = progress.center.y - h/2;
    CGRect progressRect = CGRectMake(x, y, w, h);

    //if the tap was within the HUD bezel, then react to it, ignore it
otherwise
    if(CGRectContainsPoint(progressRect, loc)){
        //do any actions here (cancel operation for example)
        [progress hide:YES];
    }else{
        //the tap location was not in the bezel region of the HUD so
igore it.
        return;
    }

}
2014-05-15 16:16:30 -04:00
Matej Bukovinski c13d794975 Merge pull request #199 from rivera-ernesto/add_suggested_warning_check
Add Xcode suggested GCC_WARN_64_TO_32_BIT_CONVERSION warning to Demo project
2014-05-13 08:36:57 +02:00
利辺羅エルネスト 913d8f37e5 Add Xcode suggested GCC_WARN_64_TO_32_BIT_CONVERSION warning to Demo project 2014-05-13 14:55:54 +09:00
Matej Bukovinski 130d31288e Merge pull request #192 from liuyaodong/patch-1
Canceling scheduled method calls inside `done`.
2014-02-25 15:14:20 +01:00
Liu Yaodong 307ca57a4c Update MBProgressHUD.m
Cancel scheduled task when -done called to fix memory issues.
2014-02-25 15:20:34 +08:00
Matej Bukovinski d775e8d985 Merge pull request #186 from holyman2k/master
fix arm 64 compiling error
2014-01-22 04:45:30 -08:00
Charlie Wu 7ffa6696c9 fix arm 64 compiling error 2014-01-20 09:53:02 +11:00
Matej Bukovinski 0fffff8031 Replacing roundf() with round() from thmath.h.
Improves 64 bit compatibility. See http://stackoverflow.com/questions/7694948/cgfloat-round-floor-abs-and-32-64-bit-precision
2013-11-14 12:29:11 +01:00
Matej Bukovinski 322af011f6 Removing the workspace .xccheckout file.
This file does not make much sense for this project see http://stackoverflow.com/questions/18340453/should-xccheckout-files-in-xcode5-be-ignored-under-vcs
2013-11-14 12:25:22 +01:00
Matej Bukovinski e879be1d22 Merge pull request #169 from nanoant/patch/fix-xcode5-warnings
Patch/fix xcode5 warnings
2013-10-30 03:14:17 -07:00
Adam Strzelecki 65ecd91445 Remove executable flags from source files 2013-10-16 17:03:28 +02:00
Adam Strzelecki da3d84ea0c Fix: Xcode 5 recommended settings
* Select architectures based on deployment target
* Use current architecture for Debug build
* Enable recommended warnings
2013-10-16 16:59:22 +02:00
Rune Botten 1f1aa50bb4 Conditionally declare the property depending on iOS target version 2013-10-04 14:45:12 +02:00
Rune Botten 7c90731626 Add dynamic property for the color of the UIActivityIndicatorView on iOS >= 5 2013-10-04 14:13:53 +02:00
Matej Bukovinski bb4a35b008 Merge pull request #167 from Club15CC/15cc-additions
Adds roundedCorner property
2013-10-02 06:33:14 -07:00
Hari Karam Singh c56e789aec Adds roundedCorner property 2013-10-01 13:14:52 +01:00
Matej Bukovinski c8e51ec1ef Added xccheckout to gitignore. 2013-10-01 10:47:15 +02:00
Matej Bukovinski a5d34f1aac Merge pull request #50 from percysnoodle/label_colors
Add labelColor and detailLabelColor to control label colours
2013-10-01 01:33:26 -07:00
Matej Bukovinski 8e0aed0409 Match the hud frame (not bounds) to the superview bounds. 2013-09-29 21:14:36 +02:00
Simon Booth 90c1ffc412 Add labelColor and detailLabelColor to control label colours 2013-07-19 08:07:46 +01:00
14 changed files with 314 additions and 257 deletions
+1
View File
@@ -5,6 +5,7 @@ build/
*.mode2v3
*.perspectivev3
xcuserdata/
*.xccheckout
# old skool
.svn
+1 -23
View File
@@ -7,30 +7,8 @@
//
#import <UIKit/UIKit.h>
#import "MBProgressHUD.h"
@interface HudDemoViewController : UIViewController <MBProgressHUDDelegate> {
MBProgressHUD *HUD;
long long expectedLength;
long long currentLength;
}
- (IBAction)showSimple:(id)sender;
- (IBAction)showWithLabel:(id)sender;
- (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;
- (IBAction)showOnWindow:(id)sender;
- (IBAction)showURL:(id)sender;
- (void)myTask;
- (void)myProgressTask;
- (void)myMixedTask;
@interface HudDemoViewController : UIViewController
@end
+31 -11
View File
@@ -7,22 +7,42 @@
//
#import "HudDemoViewController.h"
#import "MBProgressHUD.h"
#import <unistd.h>
#define SCREENSHOT_MODE 0
#ifndef kCFCoreFoundationVersionNumber_iOS_8_0
#define kCFCoreFoundationVersionNumber_iOS_7_0 847.20
#endif
@interface HudDemoViewController () <MBProgressHUDDelegate> {
MBProgressHUD *HUD;
long long expectedLength;
long long currentLength;
}
@property (retain, nonatomic) IBOutletCollection(UIButton) NSArray *buttons;
@end
@implementation HudDemoViewController
#pragma mark -
#pragma mark Lifecycle methods
#pragma mark - Lifecycle methods
- (void)viewDidLoad {
UIView *content = [[self.view subviews] objectAtIndex:0];
#if SCREENSHOT_MODE
[content.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
#endif
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) {
[self.buttons setValue:@5.f forKeyPath:@"layer.cornerRadius"];
} else {
[self.buttons setValue:nil forKey:@"backgroundColor"];
}
((UIScrollView *)self.view).contentSize = content.bounds.size;
}
@@ -36,11 +56,11 @@
}
- (void)dealloc {
[_buttons release];
[super dealloc];
}
#pragma mark -
#pragma mark IBActions
#pragma mark - Actions
- (IBAction)showSimple:(id)sender {
// The hud will dispable all input on the view (use the higest view possible in the view hierarchy)
@@ -213,7 +233,6 @@
hud.mode = MBProgressHUDModeText;
hud.labelText = @"Some message...";
hud.margin = 10.f;
hud.yOffset = 150.f;
hud.removeFromSuperViewOnHide = YES;
[hud hide:YES afterDelay:3];
@@ -230,8 +249,7 @@
[HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];
}
#pragma mark -
#pragma mark Execution code
#pragma mark - Execution code
- (void)myTask {
// Do something usefull in here instead of sleeping ...
@@ -277,8 +295,7 @@
sleep(2);
}
#pragma mark -
#pragma mark NSURLConnectionDelegete
#pragma mark - NSURLConnectionDelegete
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
expectedLength = MAX([response expectedContentLength], 1);
@@ -301,8 +318,7 @@
[HUD hide:YES];
}
#pragma mark -
#pragma mark MBProgressHUDDelegate methods
#pragma mark - MBProgressHUDDelegate
- (void)hudWasHidden:(MBProgressHUD *)hud {
// Remove HUD from screen when the HUD was hidded
@@ -311,4 +327,8 @@
HUD = nil;
}
- (void)viewDidUnload {
[self setButtons:nil];
[super viewDidUnload];
}
@end
+9 -2
View File
@@ -191,7 +191,7 @@
isa = PBXProject;
attributes = {
CLASSPREFIX = MB;
LastUpgradeCheck = 0500;
LastUpgradeCheck = 0600;
ORGANIZATIONNAME = "Matej Bukovinski";
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HudDemo" */;
@@ -306,16 +306,19 @@
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
@@ -329,15 +332,19 @@
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
SDKROOT = iphoneos;
};
name = Release;
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0600"
version = "1.8">
<BuildAction
parallelizeBuildables = "YES"
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

+100 -72
View File
@@ -1,13 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4457.9" systemVersion="12E55" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment version="528" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3682.9"/>
<deployment version="528" defaultVersion="1072" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="HudDemoViewController">
<connections>
<outlet property="view" destination="52" id="70"/>
<outletCollection property="buttons" destination="8" id="1Qm-jt-yv2"/>
<outletCollection property="buttons" destination="9" id="EHW-ch-h6c"/>
<outletCollection property="buttons" destination="10" id="g6I-6a-hVf"/>
<outletCollection property="buttons" destination="16" id="y8l-Gw-EuC"/>
<outletCollection property="buttons" destination="106" id="mfq-yU-kF4"/>
<outletCollection property="buttons" destination="117" id="Sew-7b-Taq"/>
<outletCollection property="buttons" destination="20" id="ij2-Dq-pWR"/>
<outletCollection property="buttons" destination="49" id="Ap4-YL-HTN"/>
<outletCollection property="buttons" destination="71" id="5wc-Ky-Zdq"/>
<outletCollection property="buttons" destination="76" id="N9J-sh-Sai"/>
<outletCollection property="buttons" destination="43" id="wWh-rQ-Y81"/>
<outletCollection property="buttons" destination="79" id="mUt-YM-wkJ"/>
<outletCollection property="buttons" destination="111" id="2gl-eT-6Ke"/>
<outletCollection property="buttons" destination="115" id="L2G-gy-G5K"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
@@ -19,31 +33,17 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="697"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="fill" buttonType="roundedRect" lineBreakMode="middleTruncation" id="8">
<rect key="frame" x="20" y="20" width="280" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Helvetica-Bold" family="Helvetica" pointSize="15"/>
<state key="normal" title="Simple indeterminate progress">
<color key="titleColor" red="0.19607843" green="0.30980393000000001" blue="0.52156866000000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</state>
<connections>
<action selector="showSimple:" destination="-1" eventType="touchUpInside" id="12"/>
</connections>
</button>
<button opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="fill" buttonType="roundedRect" lineBreakMode="middleTruncation" id="9">
<rect key="frame" x="20" y="68" width="280" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Helvetica-Bold" family="Helvetica" pointSize="15"/>
<color key="backgroundColor" red="0.94901960784313721" green="0.95294117647058818" blue="0.96470588235294119" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal" title="With label">
<color key="titleColor" red="0.19607843" green="0.30980393000000001" blue="0.52156866000000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleColor" red="0.0" green="0.23884613512332439" blue="0.49733664772727271" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="showWithLabel:" destination="-1" eventType="touchUpInside" id="13"/>
@@ -52,15 +52,16 @@
<button opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="fill" buttonType="roundedRect" lineBreakMode="middleTruncation" id="10">
<rect key="frame" x="20" y="116" width="280" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Helvetica-Bold" family="Helvetica" pointSize="15"/>
<color key="backgroundColor" red="0.94901960784313721" green="0.95294117647058818" blue="0.96470588235294119" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal" title="With details label">
<color key="titleColor" red="0.19607843" green="0.30980393000000001" blue="0.52156866000000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<state key="disabled" title="With details label"/>
<state key="selected" title="With details label"/>
<state key="highlighted" title="With details label">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleColor" red="0.0" green="0.23884613512332439" blue="0.49733664772727271" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="showWithDetailsLabel:" destination="-1" eventType="touchUpInside" id="14"/>
@@ -69,13 +70,14 @@
<button opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="fill" buttonType="roundedRect" lineBreakMode="middleTruncation" id="16">
<rect key="frame" x="20" y="164" width="280" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Helvetica-Bold" family="Helvetica" pointSize="15"/>
<color key="backgroundColor" red="0.94901960784313721" green="0.95294117647058818" blue="0.96470588235294119" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal" title="Determinate mode">
<color key="titleColor" red="0.19607843" green="0.30980393000000001" blue="0.52156866000000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleColor" red="0.0" green="0.23884613512332439" blue="0.49733664772727271" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="showWithLabelDeterminate:" destination="-1" eventType="touchUpInside" id="17"/>
@@ -84,13 +86,14 @@
<button opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="fill" buttonType="roundedRect" lineBreakMode="middleTruncation" id="106">
<rect key="frame" x="20" y="212" width="280" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Helvetica-Bold" family="Helvetica" pointSize="15"/>
<color key="backgroundColor" red="0.94901960784313721" green="0.95294117647058818" blue="0.96470588235294119" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal" title="Annular determinate mode">
<color key="titleColor" red="0.19607843" green="0.30980393000000001" blue="0.52156866000000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleColor" red="0.0" green="0.23884613512332439" blue="0.49733664772727271" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="showWIthLabelAnnularDeterminate:" destination="-1" eventType="touchUpInside" id="120"/>
@@ -99,13 +102,14 @@
<button opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="fill" buttonType="roundedRect" lineBreakMode="middleTruncation" id="117">
<rect key="frame" x="20" y="257" width="280" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Helvetica-Bold" family="Helvetica" pointSize="15"/>
<color key="backgroundColor" red="0.94901960784313721" green="0.95294117647058818" blue="0.96470588235294119" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal" title="Bar determinate mode">
<color key="titleColor" red="0.19607843" green="0.30980393000000001" blue="0.52156866000000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleColor" red="0.0" green="0.23884613512332439" blue="0.49733664772727271" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="showWithLabelDeterminateHorizontalBar:" destination="-1" eventType="touchUpInside" id="121"/>
@@ -114,13 +118,14 @@
<button opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="fill" buttonType="roundedRect" lineBreakMode="middleTruncation" id="20">
<rect key="frame" x="20" y="354" width="280" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Helvetica-Bold" family="Helvetica" pointSize="15"/>
<color key="backgroundColor" red="0.94901960784313721" green="0.95294117647058818" blue="0.96470588235294119" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal" title="Mode switching">
<color key="titleColor" red="0.19607843" green="0.30980393000000001" blue="0.52156866000000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleColor" red="0.0" green="0.23884613512332439" blue="0.49733664772727271" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="showWithLabelMixed:" destination="-1" eventType="touchUpInside" id="21"/>
@@ -129,13 +134,14 @@
<button opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="fill" buttonType="roundedRect" lineBreakMode="middleTruncation" id="49">
<rect key="frame" x="20" y="400" width="280" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Helvetica-Bold" family="Helvetica" pointSize="15"/>
<color key="backgroundColor" red="0.94901960784313721" green="0.95294117647058818" blue="0.96470588235294119" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal" title="Using blocks">
<color key="titleColor" red="0.19607843" green="0.30980393000000001" blue="0.52156866000000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleColor" red="0.0" green="0.23884613512332439" blue="0.49733664772727271" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="showUsingBlocks:" destination="-1" eventType="touchUpInside" id="51"/>
@@ -144,13 +150,14 @@
<button opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="fill" buttonType="roundedRect" lineBreakMode="middleTruncation" id="71">
<rect key="frame" x="20" y="450" width="280" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Helvetica-Bold" family="Helvetica" pointSize="15"/>
<color key="backgroundColor" red="0.94901960784313721" green="0.95294117647058818" blue="0.96470588235294119" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal" title="On Window">
<color key="titleColor" red="0.19607843" green="0.30980393000000001" blue="0.52156866000000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleColor" red="0.0" green="0.23884613512332439" blue="0.49733664772727271" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="showOnWindow:" destination="-1" eventType="touchUpInside" id="73"/>
@@ -159,13 +166,14 @@
<button opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="fill" buttonType="roundedRect" lineBreakMode="middleTruncation" id="76">
<rect key="frame" x="20" y="498" width="280" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Helvetica-Bold" family="Helvetica" pointSize="15"/>
<color key="backgroundColor" red="0.94901960784313721" green="0.95294117647058818" blue="0.96470588235294119" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal" title="NSURLConnection">
<color key="titleColor" red="0.19607843" green="0.30980393000000001" blue="0.52156866000000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleColor" red="0.0" green="0.23884613512332439" blue="0.49733664772727271" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="showURL:" destination="-1" eventType="touchUpInside" id="78"/>
@@ -174,13 +182,14 @@
<button opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="fill" buttonType="roundedRect" lineBreakMode="middleTruncation" id="43">
<rect key="frame" x="20" y="306" width="280" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Helvetica-Bold" family="Helvetica" pointSize="15"/>
<color key="backgroundColor" red="0.94901960784313721" green="0.95294117647058818" blue="0.96470588235294119" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal" title="Custom view">
<color key="titleColor" red="0.19607843" green="0.30980393000000001" blue="0.52156866000000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleColor" red="0.0" green="0.23884613512332439" blue="0.49733664772727271" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="showWithCustomView:" destination="-1" eventType="touchUpInside" id="47"/>
@@ -189,13 +198,14 @@
<button opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="fill" buttonType="roundedRect" lineBreakMode="middleTruncation" id="79">
<rect key="frame" x="20" y="545" width="280" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Helvetica-Bold" family="Helvetica" pointSize="15"/>
<color key="backgroundColor" red="0.94901960784313721" green="0.95294117647058818" blue="0.96470588235294119" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal" title="Dim background">
<color key="titleColor" red="0.19607843" green="0.30980393000000001" blue="0.52156866000000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleColor" red="0.0" green="0.23884613512332439" blue="0.49733664772727271" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="showWithGradient:" destination="-1" eventType="touchUpInside" id="81"/>
@@ -204,13 +214,14 @@
<button opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="fill" buttonType="roundedRect" lineBreakMode="middleTruncation" id="111">
<rect key="frame" x="20" y="593" width="280" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Helvetica-Bold" family="Helvetica" pointSize="15"/>
<color key="backgroundColor" red="0.94901960784313721" green="0.95294117647058818" blue="0.96470588235294119" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal" title="Text only">
<color key="titleColor" red="0.19607843" green="0.30980393000000001" blue="0.52156866000000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleColor" red="0.0" green="0.23884613512332439" blue="0.49733664772727271" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="showTextOnly:" destination="-1" eventType="touchUpInside" id="113"/>
@@ -219,23 +230,40 @@
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="115">
<rect key="frame" x="20" y="641" width="280" height="37"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<color key="backgroundColor" red="0.94901960784313721" green="0.95294117647058818" blue="0.96470588235294119" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal" title="Colored">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleColor" red="0.0" green="0.23884613512332439" blue="0.49733664772727271" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="showWithColor:" destination="-1" eventType="touchUpInside" id="116"/>
</connections>
</button>
<button opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="fill" buttonType="roundedRect" lineBreakMode="middleTruncation" id="8">
<rect key="frame" x="20" y="20" width="280" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.94901960784313721" green="0.95294117647058818" blue="0.96470588235294119" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal" title="Simple indeterminate progress">
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" red="0.0" green="0.23884613512332439" blue="0.49733664772727271" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="showSimple:" destination="-1" eventType="touchUpInside" id="12"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.8862745098" green="0.90588235289999997" blue="0.92941176469999998" alpha="1" colorSpace="calibratedRGB"/>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
</view>
</subviews>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
</scrollView>
</objects>
</document>
</document>
Executable → Regular
+34 -3
View File
@@ -1,6 +1,6 @@
//
// MBProgressHUD.h
// Version 0.8
// Version 0.9
// Created by Matej Bukovinski on 2.4.09.
//
@@ -344,6 +344,12 @@ typedef void (^MBProgressHUDCompletionBlock)();
*/
@property (assign) float margin;
/**
* The corner radius for the HUD
* Defaults to 10.0
*/
@property (assign) float cornerRadius;
/**
* Cover the HUD background view with a radial gradient.
*/
@@ -388,11 +394,27 @@ typedef void (^MBProgressHUDCompletionBlock)();
*/
@property (MB_STRONG) UIFont* labelFont;
/**
* Font to be used for the details label. Set this property if the default is not adequate.
/**
* Color to be used for the main label. Set this property if the default is not adequate.
*/
@property (MB_STRONG) UIColor* labelColor;
/**
* Font to be used for the details label. Set this property if the default is not adequate.
*/
@property (MB_STRONG) UIFont* detailsLabelFont;
/**
* Color to be used for the details label. Set this property if the default is not adequate.
*/
@property (MB_STRONG) UIColor* detailsLabelColor;
/**
* The color of the activity indicator. Defaults to [UIColor whiteColor]
* Does nothing on pre iOS 5.
*/
@property (MB_STRONG) UIColor *activityIndicatorColor;
/**
* The progress of the progress indicator, from 0.0 to 1.0. Defaults to 0.0.
*/
@@ -403,6 +425,15 @@ typedef void (^MBProgressHUDCompletionBlock)();
*/
@property (assign) CGSize minSize;
/**
* The actual size of the HUD bezel.
* You can use this to limit touch handling on the bezel aria only.
* @see https://github.com/jdg/MBProgressHUD/pull/200
*/
@property (atomic, assign, readonly) CGSize size;
/**
* Force the HUD dimensions to be equal if possible.
*/
Executable → Regular
+115 -100
View File
@@ -1,10 +1,11 @@
//
// MBProgressHUD.m
// Version 0.8
// Version 0.9
// Created by Matej Bukovinski on 2.4.09.
//
#import "MBProgressHUD.h"
#import <tgmath.h>
#if __has_feature(objc_arc)
@@ -39,43 +40,21 @@
sizeWithFont:font constrainedToSize:maxSize lineBreakMode:mode] : CGSizeZero;
#endif
#ifndef kCFCoreFoundationVersionNumber_iOS_7_0
#define kCFCoreFoundationVersionNumber_iOS_7_0 847.20
#endif
#ifndef kCFCoreFoundationVersionNumber_iOS_8_0
#define kCFCoreFoundationVersionNumber_iOS_8_0 1129.15
#endif
static const CGFloat kPadding = 4.f;
static const CGFloat kLabelFontSize = 16.f;
static const CGFloat kDetailsLabelFontSize = 12.f;
@interface MBProgressHUD ()
- (void)setupLabels;
- (void)registerForKVO;
- (void)unregisterFromKVO;
- (NSArray *)observableKeypaths;
- (void)registerForNotifications;
- (void)unregisterFromNotifications;
- (void)updateUIForKeypath:(NSString *)keyPath;
- (void)hideUsingAnimation:(BOOL)animated;
- (void)showUsingAnimation:(BOOL)animated;
- (void)done;
- (void)updateIndicators;
- (void)handleGraceTimer:(NSTimer *)theTimer;
- (void)handleMinShowTimer:(NSTimer *)theTimer;
- (void)setTransformForCurrentOrientation:(BOOL)animated;
- (void)cleanUp;
- (void)launchExecution;
- (void)deviceOrientationDidChange:(NSNotification *)notification;
- (void)hideDelayed:(NSNumber *)animated;
@property (atomic, MB_STRONG) UIView *indicator;
@property (atomic, MB_STRONG) NSTimer *graceTimer;
@property (atomic, MB_STRONG) NSTimer *minShowTimer;
@property (atomic, MB_STRONG) NSDate *showStarted;
@property (atomic, assign) CGSize size;
@end
@implementation MBProgressHUD {
@interface MBProgressHUD () {
BOOL useAnimation;
SEL methodForExecution;
id targetForExecution;
@@ -86,6 +65,17 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
CGAffineTransform rotationTransform;
}
@property (atomic, MB_STRONG) UIView *indicator;
@property (atomic, MB_STRONG) NSTimer *graceTimer;
@property (atomic, MB_STRONG) NSTimer *minShowTimer;
@property (atomic, MB_STRONG) NSDate *showStarted;
@end
@implementation MBProgressHUD
#pragma mark - Properties
@synthesize animationType;
@@ -93,7 +83,9 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
@synthesize opacity;
@synthesize color;
@synthesize labelFont;
@synthesize labelColor;
@synthesize detailsLabelFont;
@synthesize detailsLabelColor;
@synthesize indicator;
@synthesize xOffset;
@synthesize yOffset;
@@ -114,6 +106,7 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
@synthesize detailsLabelText;
@synthesize progress;
@synthesize size;
@synthesize activityIndicatorColor;
#if NS_BLOCKS_AVAILABLE
@synthesize completionBlock;
#endif
@@ -178,19 +171,24 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
self.labelText = nil;
self.detailsLabelText = nil;
self.opacity = 0.8f;
self.color = nil;
self.color = nil;
self.labelFont = [UIFont boldSystemFontOfSize:kLabelFontSize];
self.labelColor = [UIColor whiteColor];
self.detailsLabelFont = [UIFont boldSystemFontOfSize:kDetailsLabelFontSize];
self.detailsLabelColor = [UIColor whiteColor];
self.activityIndicatorColor = [UIColor whiteColor];
self.xOffset = 0.0f;
self.yOffset = 0.0f;
self.dimBackground = NO;
self.margin = 20.0f;
self.cornerRadius = 10.0f;
self.graceTime = 0.0f;
self.minShowTime = 0.0f;
self.removeFromSuperViewOnHide = NO;
self.minSize = CGSizeZero;
self.square = NO;
self.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin
self.contentMode = UIViewContentModeCenter;
self.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin
| UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
// Transparent background
@@ -233,6 +231,10 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
[minShowTimer release];
[showStarted release];
[customView release];
[labelFont release];
[labelColor release];
[detailsLabelFont release];
[detailsLabelColor release];
#if NS_BLOCKS_AVAILABLE
[completionBlock release];
#endif
@@ -296,9 +298,14 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
#pragma mark - View Hierrarchy
- (BOOL)shouldPerformOrientationTransform {
BOOL isPreiOS8 = NSFoundationVersionNumber < kCFCoreFoundationVersionNumber_iOS_8_0;
// prior to iOS8 code needs to take care of rotation if it is being added to the window
return isPreiOS8 && [self.superview isKindOfClass:[UIWindow class]];
}
- (void)didMoveToSuperview {
// We need to take care of rotation ourselfs if we're adding the HUD to a window
if ([self.superview isKindOfClass:[UIWindow class]]) {
if ([self shouldPerformOrientationTransform]) {
[self setTransformForCurrentOrientation:NO];
}
}
@@ -357,6 +364,7 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
}
- (void)done {
[NSObject cancelPreviousPerformRequestsWithTarget:self];
isFinished = YES;
self.alpha = 0.0f;
if (removeFromSuperViewOnHide) {
@@ -407,12 +415,12 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
self.taskInProgress = YES;
self.completionBlock = completion;
dispatch_async(queue, ^(void) {
block();
dispatch_async(dispatch_get_main_queue(), ^(void) {
[self cleanUp];
});
});
[self show:animated];
block();
dispatch_async(dispatch_get_main_queue(), ^(void) {
[self cleanUp];
});
});
[self show:animated];
}
#endif
@@ -450,7 +458,7 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
label.textAlignment = MBLabelAlignmentCenter;
label.opaque = NO;
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor whiteColor];
label.textColor = self.labelColor;
label.font = self.labelFont;
label.text = self.labelText;
[self addSubview:label];
@@ -461,7 +469,7 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
detailsLabel.textAlignment = MBLabelAlignmentCenter;
detailsLabel.opaque = NO;
detailsLabel.backgroundColor = [UIColor clearColor];
detailsLabel.textColor = [UIColor whiteColor];
detailsLabel.textColor = self.detailsLabelColor;
detailsLabel.numberOfLines = 0;
detailsLabel.font = self.detailsLabelFont;
detailsLabel.text = self.detailsLabelText;
@@ -473,18 +481,23 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
BOOL isActivityIndicator = [indicator isKindOfClass:[UIActivityIndicatorView class]];
BOOL isRoundIndicator = [indicator isKindOfClass:[MBRoundProgressView class]];
if (mode == MBProgressHUDModeIndeterminate && !isActivityIndicator) {
// Update to indeterminate indicator
[indicator removeFromSuperview];
self.indicator = MB_AUTORELEASE([[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]);
[(UIActivityIndicatorView *)indicator startAnimating];
[self addSubview:indicator];
if (mode == MBProgressHUDModeIndeterminate) {
if (!isActivityIndicator) {
// Update to indeterminate indicator
[indicator removeFromSuperview];
self.indicator = MB_AUTORELEASE([[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]);
[(UIActivityIndicatorView *)indicator startAnimating];
[self addSubview:indicator];
}
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 50000
[(UIActivityIndicatorView *)indicator setColor:self.activityIndicatorColor];
#endif
}
else if (mode == MBProgressHUDModeDeterminateHorizontalBar) {
// Update to bar determinate indicator
[indicator removeFromSuperview];
self.indicator = MB_AUTORELEASE([[MBBarProgressView alloc] init]);
self.indicator = MB_AUTORELEASE([[MBBarProgressView alloc] init]);
[self addSubview:indicator];
}
else if (mode == MBProgressHUDModeDeterminate || mode == MBProgressHUDModeAnnularDeterminate) {
@@ -512,6 +525,7 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
#pragma mark - Layout
- (void)layoutSubviews {
[super layoutSubviews];
// Entirely cover the parent view
UIView *parent = self.superview;
@@ -550,10 +564,10 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
totalSize.height += 2 * margin;
// Position elements
CGFloat yPos = roundf(((bounds.size.height - totalSize.height) / 2)) + margin + yOffset;
CGFloat yPos = round(((bounds.size.height - totalSize.height) / 2)) + margin + yOffset;
CGFloat xPos = xOffset;
indicatorF.origin.y = yPos;
indicatorF.origin.x = roundf((bounds.size.width - indicatorF.size.width) / 2) + xPos;
indicatorF.origin.x = round((bounds.size.width - indicatorF.size.width) / 2) + xPos;
indicator.frame = indicatorF;
yPos += indicatorF.size.height;
@@ -562,7 +576,7 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
}
CGRect labelF;
labelF.origin.y = yPos;
labelF.origin.x = roundf((bounds.size.width - labelSize.width) / 2) + xPos;
labelF.origin.x = round((bounds.size.width - labelSize.width) / 2) + xPos;
labelF.size = labelSize;
label.frame = labelF;
yPos += labelF.size.height;
@@ -572,7 +586,7 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
}
CGRect detailsLabelF;
detailsLabelF.origin.y = yPos;
detailsLabelF.origin.x = roundf((bounds.size.width - detailsLabelSize.width) / 2) + xPos;
detailsLabelF.origin.x = round((bounds.size.width - detailsLabelSize.width) / 2) + xPos;
detailsLabelF.size = detailsLabelSize;
detailsLabel.frame = detailsLabelF;
@@ -593,7 +607,7 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
totalSize.height = minSize.height;
}
self.size = totalSize;
size = totalSize;
}
#pragma mark BG Drawing
@@ -622,20 +636,20 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
CGGradientRelease(gradient);
}
// Set background rect color
if (self.color) {
CGContextSetFillColorWithColor(context, self.color.CGColor);
} else {
CGContextSetGrayFillColor(context, 0.0f, self.opacity);
}
// Set background rect color
if (self.color) {
CGContextSetFillColorWithColor(context, self.color.CGColor);
} else {
CGContextSetGrayFillColor(context, 0.0f, self.opacity);
}
// Center HUD
CGRect allRect = self.bounds;
// Draw rounded HUD backgroud rect
CGRect boxRect = CGRectMake(roundf((allRect.size.width - size.width) / 2) + self.xOffset,
roundf((allRect.size.height - size.height) / 2) + self.yOffset, size.width, size.height);
float radius = 10.0f;
CGRect boxRect = CGRectMake(round((allRect.size.width - size.width) / 2) + self.xOffset,
round((allRect.size.height - size.height) / 2) + self.yOffset, size.width, size.height);
float radius = self.cornerRadius;
CGContextBeginPath(context);
CGContextMoveToPoint(context, CGRectGetMinX(boxRect) + radius, CGRectGetMinY(boxRect));
CGContextAddArc(context, CGRectGetMaxX(boxRect) - radius, CGRectGetMinY(boxRect) + radius, radius, 3 * (float)M_PI / 2, 0, 0);
@@ -663,8 +677,8 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
}
- (NSArray *)observableKeypaths {
return [NSArray arrayWithObjects:@"mode", @"customView", @"labelText", @"labelFont",
@"detailsLabelText", @"detailsLabelFont", @"progress", nil];
return [NSArray arrayWithObjects:@"mode", @"customView", @"labelText", @"labelFont", @"labelColor",
@"detailsLabelText", @"detailsLabelFont", @"detailsLabelColor", @"progress", @"activityIndicatorColor", nil];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
@@ -676,19 +690,24 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
}
- (void)updateUIForKeypath:(NSString *)keyPath {
if ([keyPath isEqualToString:@"mode"] || [keyPath isEqualToString:@"customView"]) {
if ([keyPath isEqualToString:@"mode"] || [keyPath isEqualToString:@"customView"] ||
[keyPath isEqualToString:@"activityIndicatorColor"]) {
[self updateIndicators];
} else if ([keyPath isEqualToString:@"labelText"]) {
label.text = self.labelText;
} else if ([keyPath isEqualToString:@"labelFont"]) {
label.font = self.labelFont;
} else if ([keyPath isEqualToString:@"labelColor"]) {
label.textColor = self.labelColor;
} else if ([keyPath isEqualToString:@"detailsLabelText"]) {
detailsLabel.text = self.detailsLabelText;
} else if ([keyPath isEqualToString:@"detailsLabelFont"]) {
detailsLabel.font = self.detailsLabelFont;
} else if ([keyPath isEqualToString:@"detailsLabelColor"]) {
detailsLabel.textColor = self.detailsLabelColor;
} else if ([keyPath isEqualToString:@"progress"]) {
if ([indicator respondsToSelector:@selector(setProgress:)]) {
[(id)indicator setProgress:progress];
[(id)indicator setValue:@(progress) forKey:@"progress"];
}
return;
}
@@ -700,27 +719,29 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
- (void)registerForNotifications {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(deviceOrientationDidChange:)
name:UIDeviceOrientationDidChangeNotification object:nil];
[nc addObserver:self selector:@selector(statusBarOrientationDidChange:)
name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
}
- (void)unregisterFromNotifications {
[[NSNotificationCenter defaultCenter] removeObserver:self];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc removeObserver:self name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
}
- (void)deviceOrientationDidChange:(NSNotification *)notification {
- (void)statusBarOrientationDidChange:(NSNotification *)notification {
UIView *superview = self.superview;
if (!superview) {
return;
} else if ([superview isKindOfClass:[UIWindow class]]) {
} else if ([self shouldPerformOrientationTransform]) {
[self setTransformForCurrentOrientation:YES];
} else {
self.bounds = self.superview.bounds;
self.frame = self.superview.bounds;
[self setNeedsDisplay];
}
}
- (void)setTransformForCurrentOrientation:(BOOL)animated {
- (void)setTransformForCurrentOrientation:(BOOL)animated {
// Stay in sync with the superview
if (self.superview) {
self.bounds = self.superview.bounds;
@@ -742,6 +763,7 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
if (animated) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
}
[self setTransform:rotationTransform];
if (animated) {
@@ -793,10 +815,11 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
if (_annular) {
// Draw background
CGFloat lineWidth = 5.f;
BOOL isPreiOS7 = NSFoundationVersionNumber < kCFCoreFoundationVersionNumber_iOS_7_0;
CGFloat lineWidth = isPreiOS7 ? 5.f : 2.f;
UIBezierPath *processBackgroundPath = [UIBezierPath bezierPath];
processBackgroundPath.lineWidth = lineWidth;
processBackgroundPath.lineCapStyle = kCGLineCapRound;
processBackgroundPath.lineCapStyle = kCGLineCapButt;
CGPoint center = CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2);
CGFloat radius = (self.bounds.size.width - lineWidth)/2;
CGFloat startAngle = - ((float)M_PI / 2); // 90 degrees
@@ -806,7 +829,7 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
[processBackgroundPath stroke];
// Draw progress
UIBezierPath *processPath = [UIBezierPath bezierPath];
processPath.lineCapStyle = kCGLineCapRound;
processPath.lineCapStyle = isPreiOS7 ? kCGLineCapRound : kCGLineCapSquare;
processPath.lineWidth = lineWidth;
endAngle = (self.progress * 2 * (float)M_PI) + startAngle;
[processPath addArcWithCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES];
@@ -866,8 +889,8 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
}
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self = [super initWithFrame:frame];
if (self) {
_progress = 0.f;
_lineColor = [UIColor whiteColor];
_progressColor = [UIColor whiteColor];
@@ -875,8 +898,8 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
self.backgroundColor = [UIColor clearColor];
self.opaque = NO;
[self registerForKVO];
}
return self;
}
return self;
}
- (void)dealloc {
@@ -894,12 +917,11 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
// setup properties
CGContextSetLineWidth(context, 2);
CGContextSetStrokeColorWithColor(context,[_lineColor CGColor]);
CGContextSetFillColorWithColor(context, [_progressRemainingColor CGColor]);
// draw line border
// Draw background
float radius = (rect.size.height / 2) - 2;
CGContextMoveToPoint(context, 2, rect.size.height/2);
CGContextAddArcToPoint(context, 2, 2, radius + 2, 2, radius);
@@ -910,7 +932,7 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
CGContextAddArcToPoint(context, 2, rect.size.height - 2, 2, rect.size.height/2, radius);
CGContextFillPath(context);
// draw progress background
// Draw border
CGContextMoveToPoint(context, 2, rect.size.height/2);
CGContextAddArcToPoint(context, 2, 2, radius + 2, 2, radius);
CGContextAddLineToPoint(context, rect.size.width - radius - 2, 2);
@@ -920,20 +942,17 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
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
// Progress 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);
@@ -942,11 +961,10 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
CGContextFillPath(context);
}
// progress is in the right arc
// Progress 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);
@@ -954,8 +972,7 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
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);
@@ -967,14 +984,12 @@ static const CGFloat kDetailsLabelFontSize = 12.f;
CGContextFillPath(context);
}
// progress is in the left arc
// 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);
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "MBProgressHUD"
s.version = "0.8"
s.version = "0.9"
s.summary = "An iOS activity indicator view."
s.description = <<-DESC
MBProgressHUD is an iOS drop-in class that displays a translucent HUD
+11 -4
View File
@@ -159,9 +159,9 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
@@ -177,10 +177,14 @@
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
@@ -189,9 +193,9 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
@@ -200,10 +204,13 @@
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -39,6 +39,15 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D286A7481518C70F00E13FB8"
BuildableName = "libMBProgressHUD.a"
BlueprintName = "MBProgressHUD"
ReferencedContainer = "container:MBProgressHUD.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
@@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectIdentifier</key>
<string>56AFB412-8D27-4BA2-8013-D55F9BFC45C2</string>
<key>IDESourceControlProjectName</key>
<string>MBProgressHUD</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>EC408792-857F-4597-A622-50F7402BBD62</key>
<string>ssh://github.com/matej/MBProgressHUD.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>MBProgressHUD.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>EC408792-857F-4597-A622-50F7402BBD62</key>
<string>..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>ssh://github.com/matej/MBProgressHUD.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>EC408792-857F-4597-A622-50F7402BBD62</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>EC408792-857F-4597-A622-50F7402BBD62</string>
<key>IDESourceControlWCCName</key>
<string>MBProgressHUD</string>
</dict>
</array>
</dict>
</plist>