Skip to content

Commit c89079d

Browse files
committed
Fixed invalid context error: Issue #35
1 parent 31fec48 commit c89079d

File tree

3 files changed

+91
-50
lines changed

3 files changed

+91
-50
lines changed

Classes/HUD/M13ProgressHUD.m

Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ - (void)show:(BOOL)animated
301301
[self setNeedsDisplay];
302302

303303
onScreen = YES;
304-
304+
305305
//Animate the HUD on screen
306306
CABasicAnimation *fadeAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
307307
fadeAnimation.duration = _animationDuration;
@@ -329,7 +329,7 @@ - (void)show:(BOOL)animated
329329
{
330330
positionAnimation.fromValue = [NSValue valueWithCGPoint:_animationPoint];
331331
}
332-
332+
333333
positionAnimation.toValue = [NSValue valueWithCGPoint:backgroundView.layer.position];
334334
positionAnimation.removedOnCompletion = YES;
335335

@@ -350,15 +350,15 @@ - (void)hide:(BOOL)animated
350350
fadeAnimation.fromValue = [NSNumber numberWithFloat:1.0];
351351
fadeAnimation.toValue = [NSNumber numberWithFloat:0.0];
352352
fadeAnimation.removedOnCompletion = YES;
353-
353+
354354
[self.layer addAnimation:fadeAnimation forKey:@"fadeAnimation"];
355355
self.layer.opacity = 0.0;
356356

357357
CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
358358
scaleAnimation.fromValue = [NSNumber numberWithFloat:1.0];
359359
scaleAnimation.toValue = [NSNumber numberWithFloat:0.0];
360360
scaleAnimation.removedOnCompletion = YES;
361-
361+
362362
CABasicAnimation *frameAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
363363

364364
if (_animationCentered)
@@ -407,7 +407,7 @@ - (void)unregisterFromNotificationCenter {
407407

408408
- (void)deviceOrientationDidChange:(NSNotification *)notification {
409409
UIDeviceOrientation deviceOrientation = [notification.object orientation];
410-
410+
411411
if (_shouldAutorotate && UIDeviceOrientationIsValidInterfaceOrientation(deviceOrientation)) {
412412
if (UIDeviceOrientationIsPortrait(deviceOrientation)) {
413413
if (deviceOrientation == UIDeviceOrientationPortraitUpsideDown) {
@@ -556,7 +556,7 @@ - (void)layoutHUD
556556
}
557557

558558
backgroundRect.origin.x = (self.bounds.size.width / 2.0) - (backgroundRect.size.width / 2.0);
559-
backgroundRect.origin.y = (self.bounds.size.height / 2.0) - (_minimumSize.height / 2.0);
559+
backgroundRect.origin.y = (self.bounds.size.height / 2.0) - (_minimumSize.height / 2.0);
560560

561561
//There is no status label text, center the progress view
562562
progressRect.origin.x = (backgroundRect.size.width / 2.0) - (progressRect.size.width / 2.0);
@@ -696,6 +696,11 @@ - (void)drawMask
696696
//Create the gradient as an image, and then set it as the color of the mask view.
697697
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, [UIScreen mainScreen].scale);
698698
CGContextRef context = UIGraphicsGetCurrentContext();
699+
700+
if (!context) {
701+
return;
702+
}
703+
699704
//Create the gradient
700705
size_t locationsCount = 2;
701706
CGFloat locations[2] = {0.0f, 1.0f};
@@ -713,52 +718,53 @@ - (void)drawMask
713718
UIGraphicsEndImageContext();
714719
//Set the background
715720
maskView.backgroundColor = [UIColor colorWithPatternImage:image];
721+
716722
} else if (_maskType == M13ProgressHUDMaskTypeIOS7Blur) {
717723
// do nothing; we don't want to take a snapshot of the background for blurring now, no idea what the background is
718724
}
719725
}
720726

721727
- (void)redrawBlurs
722728
{
723-
if (_maskType == M13ProgressHUDMaskTypeIOS7Blur) {
724-
//Get the snapshot of the mask
725-
__block UIImage *image = [self snapshotForBlurredBackgroundInView:maskView];
726-
if (image != nil) {
727-
//Apply the filters to blur the image
728-
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
729-
image = [image applyLightEffect];
730-
dispatch_async(dispatch_get_main_queue(), ^{
731-
// Fade on content's change, if there was already an image.
732-
CATransition *transition = [CATransition new];
733-
transition.duration = 0.3;
734-
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
735-
transition.type = kCATransitionFade;
736-
[self->maskView.layer addAnimation:transition forKey:nil];
737-
self->maskView.backgroundColor = [UIColor colorWithPatternImage:image];
738-
});
729+
if (_maskType == M13ProgressHUDMaskTypeIOS7Blur) {
730+
//Get the snapshot of the mask
731+
__block UIImage *image = [self snapshotForBlurredBackgroundInView:maskView];
732+
if (image != nil) {
733+
//Apply the filters to blur the image
734+
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
735+
image = [image applyLightEffect];
736+
dispatch_async(dispatch_get_main_queue(), ^{
737+
// Fade on content's change, if there was already an image.
738+
CATransition *transition = [CATransition new];
739+
transition.duration = 0.3;
740+
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
741+
transition.type = kCATransitionFade;
742+
[self->maskView.layer addAnimation:transition forKey:nil];
743+
self->maskView.backgroundColor = [UIColor colorWithPatternImage:image];
739744
});
740-
}
745+
});
741746
}
742-
if (_applyBlurToBackground) {
743-
//Get the snapshot of the mask
744-
__block UIImage *image = [self snapshotForBlurredBackgroundInView:backgroundView];
745-
if (image != nil) {
746-
//Apply the filters to blur the image
747-
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
748-
//image = [image applyLightEffect];
749-
image = [image applyLightEffect];
750-
dispatch_async(dispatch_get_main_queue(), ^{
751-
// Fade on content's change, if there was already an image.
752-
CATransition *transition = [CATransition new];
753-
transition.duration = 0.3;
754-
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
755-
transition.type = kCATransitionFade;
756-
[self->backgroundView.layer addAnimation:transition forKey:nil];
757-
self->backgroundView.backgroundColor = [UIColor colorWithPatternImage:image];
758-
});
747+
}
748+
if (_applyBlurToBackground) {
749+
//Get the snapshot of the mask
750+
__block UIImage *image = [self snapshotForBlurredBackgroundInView:backgroundView];
751+
if (image != nil) {
752+
//Apply the filters to blur the image
753+
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
754+
//image = [image applyLightEffect];
755+
image = [image applyLightEffect];
756+
dispatch_async(dispatch_get_main_queue(), ^{
757+
// Fade on content's change, if there was already an image.
758+
CATransition *transition = [CATransition new];
759+
transition.duration = 0.3;
760+
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
761+
transition.type = kCATransitionFade;
762+
[self->backgroundView.layer addAnimation:transition forKey:nil];
763+
self->backgroundView.backgroundColor = [UIColor colorWithPatternImage:image];
759764
});
760-
}
765+
});
761766
}
767+
}
762768
}
763769

764770
- (UIImage *)snapshotForBlurredBackgroundInView:(UIView *)view

M13ProgressSuite.xcodeproj/project.pbxproj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
62BB86001C87300F0019306A /* UIApplication+M13ProgressSuite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIApplication+M13ProgressSuite.m"; path = "Classes/Application/UIApplication+M13ProgressSuite.m"; sourceTree = "<group>"; };
135135
CA1C945C18CCF59500B469BF /* M13ProgressViewMetroDotPolygon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = M13ProgressViewMetroDotPolygon.h; path = Classes/ProgressViews/M13ProgressViewMetroDotPolygon.h; sourceTree = "<group>"; };
136136
CA1C945D18CCF59500B469BF /* M13ProgressViewMetroDotPolygon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = M13ProgressViewMetroDotPolygon.m; path = Classes/ProgressViews/M13ProgressViewMetroDotPolygon.m; sourceTree = "<group>"; };
137-
CA2FAF981889907300BCAEF5 /* M13ProgressSuite.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = M13ProgressSuite.app; sourceTree = BUILT_PRODUCTS_DIR; };
137+
CA2FAF981889907300BCAEF5 /* M13ProgressSuiteDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = M13ProgressSuiteDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
138138
CA2FAF9B1889907300BCAEF5 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
139139
CA2FAF9D1889907300BCAEF5 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
140140
CA2FAF9F1889907300BCAEF5 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
@@ -288,7 +288,7 @@
288288
CA2FAF991889907300BCAEF5 /* Products */ = {
289289
isa = PBXGroup;
290290
children = (
291-
CA2FAF981889907300BCAEF5 /* M13ProgressSuite.app */,
291+
CA2FAF981889907300BCAEF5 /* M13ProgressSuiteDemo.app */,
292292
CA2FAFBC1889907300BCAEF5 /* M13ProgressSuiteTests.xctest */,
293293
FB2A7BDC1B793E5600FE4E4A /* M13ProgressSuite.framework */,
294294
);
@@ -629,9 +629,9 @@
629629
/* End PBXHeadersBuildPhase section */
630630

631631
/* Begin PBXNativeTarget section */
632-
CA2FAF971889907300BCAEF5 /* M13ProgressSuite */ = {
632+
CA2FAF971889907300BCAEF5 /* M13ProgressSuiteDemo */ = {
633633
isa = PBXNativeTarget;
634-
buildConfigurationList = CA2FAFCD1889907300BCAEF5 /* Build configuration list for PBXNativeTarget "M13ProgressSuite" */;
634+
buildConfigurationList = CA2FAFCD1889907300BCAEF5 /* Build configuration list for PBXNativeTarget "M13ProgressSuiteDemo" */;
635635
buildPhases = (
636636
CA2FAF941889907300BCAEF5 /* Sources */,
637637
CA2FAF951889907300BCAEF5 /* Frameworks */,
@@ -643,9 +643,9 @@
643643
dependencies = (
644644
FB2A7BF21B793E5600FE4E4A /* PBXTargetDependency */,
645645
);
646-
name = M13ProgressSuite;
646+
name = M13ProgressSuiteDemo;
647647
productName = M13ProgressSuite;
648-
productReference = CA2FAF981889907300BCAEF5 /* M13ProgressSuite.app */;
648+
productReference = CA2FAF981889907300BCAEF5 /* M13ProgressSuiteDemo.app */;
649649
productType = "com.apple.product-type.application";
650650
};
651651
CA2FAFBB1889907300BCAEF5 /* M13ProgressSuiteTests */ = {
@@ -714,7 +714,7 @@
714714
projectDirPath = "";
715715
projectRoot = "";
716716
targets = (
717-
CA2FAF971889907300BCAEF5 /* M13ProgressSuite */,
717+
CA2FAF971889907300BCAEF5 /* M13ProgressSuiteDemo */,
718718
CA2FAFBB1889907300BCAEF5 /* M13ProgressSuiteTests */,
719719
FB2A7BDB1B793E5600FE4E4A /* M13ProgressSuiteFramework */,
720720
CA2FB0431889986D00BCAEF5 /* Documentation */,
@@ -834,7 +834,7 @@
834834
/* Begin PBXTargetDependency section */
835835
CA2FAFC21889907300BCAEF5 /* PBXTargetDependency */ = {
836836
isa = PBXTargetDependency;
837-
target = CA2FAF971889907300BCAEF5 /* M13ProgressSuite */;
837+
target = CA2FAF971889907300BCAEF5 /* M13ProgressSuiteDemo */;
838838
targetProxy = CA2FAFC11889907300BCAEF5 /* PBXContainerItemProxy */;
839839
};
840840
FB2A7BF21B793E5600FE4E4A /* PBXTargetDependency */ = {
@@ -1112,7 +1112,7 @@
11121112
defaultConfigurationIsVisible = 0;
11131113
defaultConfigurationName = Release;
11141114
};
1115-
CA2FAFCD1889907300BCAEF5 /* Build configuration list for PBXNativeTarget "M13ProgressSuite" */ = {
1115+
CA2FAFCD1889907300BCAEF5 /* Build configuration list for PBXNativeTarget "M13ProgressSuiteDemo" */ = {
11161116
isa = XCConfigurationList;
11171117
buildConfigurations = (
11181118
CA2FAFCE1889907300BCAEF5 /* Debug */,

M13ProgressSuite/Images.xcassets/AppIcon.appiconset/Contents.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
11
{
22
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "20x20",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "20x20",
11+
"scale" : "3x"
12+
},
313
{
414
"size" : "29x29",
515
"idiom" : "iphone",
616
"filename" : "[email protected]",
717
"scale" : "2x"
818
},
19+
{
20+
"idiom" : "iphone",
21+
"size" : "29x29",
22+
"scale" : "3x"
23+
},
924
{
1025
"size" : "40x40",
1126
"idiom" : "iphone",
1227
"filename" : "[email protected]",
1328
"scale" : "2x"
1429
},
30+
{
31+
"idiom" : "iphone",
32+
"size" : "40x40",
33+
"scale" : "3x"
34+
},
1535
{
1636
"size" : "60x60",
1737
"idiom" : "iphone",
@@ -24,6 +44,16 @@
2444
"filename" : "[email protected]",
2545
"scale" : "3x"
2646
},
47+
{
48+
"idiom" : "ipad",
49+
"size" : "20x20",
50+
"scale" : "1x"
51+
},
52+
{
53+
"idiom" : "ipad",
54+
"size" : "20x20",
55+
"scale" : "2x"
56+
},
2757
{
2858
"size" : "29x29",
2959
"idiom" : "ipad",
@@ -59,6 +89,11 @@
5989
"idiom" : "ipad",
6090
"filename" : "[email protected]",
6191
"scale" : "2x"
92+
},
93+
{
94+
"idiom" : "ipad",
95+
"size" : "83.5x83.5",
96+
"scale" : "2x"
6297
}
6398
],
6499
"info" : {

0 commit comments

Comments
 (0)