├── .gitignore ├── FancyCrash ├── FancyCrash.h └── FancyCrash.m ├── FancyCrashTest.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── FancyCrashTest ├── AppDelegate.h ├── AppDelegate.m ├── FancyCrashTest-Info.plist ├── FancyCrashTest-Prefix.pch ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── LaunchImage.launchimage │ │ └── Contents.json │ └── background.imageset │ │ ├── Contents.json │ │ ├── background.png │ │ └── background@2x.png ├── MainViewController.h ├── MainViewController.m ├── MainViewController.xib ├── en.lproj │ └── InfoPlist.strings └── main.m ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | */build/* 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | profile 14 | *.moved-aside 15 | DerivedData 16 | .idea/ 17 | *.hmap 18 | *.xccheckout 19 | 20 | #CocoaPods 21 | Pods 22 | -------------------------------------------------------------------------------- /FancyCrash/FancyCrash.h: -------------------------------------------------------------------------------- 1 | // 2 | // FancyCrash.h 3 | // FancyCrashTest 4 | // 5 | // Created by Wang Xiaolei on 3/26/14. 6 | // Copyright (c) 2014 Wang Xiaolei. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSUInteger, FancyCrashEffect) 12 | { 13 | kFancyCrashEffectNone = 0, // Silent crash 14 | 15 | /** 16 | * Options: 17 | * @"crackDuration" : @0.5, // crack animation duration 18 | * @"fallDuration" : @0.9, // fall animation duration 19 | * @"rows" : @6, // row count 20 | * @"columns" : @4, // column count 21 | */ 22 | kFancyCrashEffectBreakGlass1, 23 | 24 | kFancyCrashEffectLast = kFancyCrashEffectBreakGlass1 25 | }; 26 | 27 | @interface FancyCrash : NSObject 28 | 29 | /** 30 | * Crash App with random effect. 31 | */ 32 | + (void)crash; 33 | 34 | /** 35 | * Crash App with specific effect and custom options. 36 | */ 37 | + (void)crashWithEffect:(FancyCrashEffect)effect effectOptions:(NSDictionary *)options; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /FancyCrash/FancyCrash.m: -------------------------------------------------------------------------------- 1 | // 2 | // FancyCrash.m 3 | // FancyCrashTest 4 | // 5 | // Created by Wang Xiaolei on 3/26/14. 6 | // Copyright (c) 2014 Wang Xiaolei. All rights reserved. 7 | // 8 | 9 | #import "FancyCrash.h" 10 | @import QuartzCore; 11 | 12 | #pragma mark - FCImagePiece 13 | 14 | /** 15 | * Splitted image piece 16 | */ 17 | @interface FCImagePiece : NSObject 18 | @property (assign, nonatomic) CGPoint position; 19 | @property (retain, nonatomic) NSArray *corners; 20 | @property (retain, nonatomic) UIImage *image; 21 | @end 22 | 23 | @implementation FCImagePiece 24 | @end 25 | 26 | #pragma mark - FancyCrash class 27 | 28 | @interface FancyCrash () 29 | @property (retain, nonatomic) NSDictionary *effectOptions; 30 | @end 31 | 32 | @implementation FancyCrash 33 | 34 | + (void)crash 35 | { 36 | FancyCrashEffect effect = (arc4random() % kFancyCrashEffectLast) + 1; 37 | [FancyCrash crashWithEffect:effect effectOptions:nil]; 38 | } 39 | 40 | + (void)crashWithEffect:(FancyCrashEffect)effect effectOptions:(NSDictionary *)options 41 | { 42 | FancyCrash *crash = [FancyCrash new]; 43 | crash.effectOptions = options; 44 | 45 | switch (effect) { 46 | case kFancyCrashEffectBreakGlass1: 47 | [crash breakGlass1]; 48 | break; 49 | 50 | default: 51 | [crash exitApp]; 52 | break; 53 | } 54 | } 55 | 56 | #pragma mark - Effects 57 | 58 | // random double in [0, 1] 59 | static double randomDouble01() 60 | { 61 | return ((int)arc4random() % 101) / 100.0; 62 | } 63 | 64 | // random double in [-1, 1] 65 | static double randomDouble11() 66 | { 67 | return ((int)arc4random() % 201 - 100) / 100.0; 68 | } 69 | 70 | - (void)breakGlass1 71 | { 72 | NSTimeInterval crackDuration = [self doubleOptionForKey:@"crackDuration" defaultValue:0.5]; 73 | NSTimeInterval fallDuration = [self doubleOptionForKey:@"fallDuration" defaultValue:0.9]; 74 | NSInteger rows = [self integerOptionForKey:@"rows" defaultValue:6]; 75 | NSInteger columns = [self integerOptionForKey:@"columns" defaultValue:4]; 76 | fallDuration = MAX(fallDuration, 0.2); 77 | rows = MAX(rows, 2); 78 | columns = MAX(columns, 2); 79 | 80 | NSTimeInterval totalDuration = crackDuration + fallDuration; 81 | 82 | // animation container 83 | UIViewController *animController = [UIViewController new]; 84 | UIView *animView = animController.view; 85 | animView.backgroundColor = [UIColor blackColor]; 86 | 87 | // break screenshot into pieces 88 | UIImage *screenshot = [self takeScreenshot]; 89 | NSArray *pieces = [self polygonSplitImage:screenshot intoRows:rows columns:columns]; 90 | 91 | // joint image pieces to fake current UI 92 | NSMutableArray *allPicLayers = [NSMutableArray arrayWithCapacity:pieces.count]; 93 | for (NSInteger r = 0; r < rows; r++) { 94 | for (NSInteger c = 0; c < columns; c++) { 95 | FCImagePiece *piece = pieces[r * columns + c]; 96 | CALayer *picLayer = [CALayer layer]; 97 | picLayer.contents = (__bridge id)[piece.image CGImage]; 98 | picLayer.frame = CGRectMake(piece.position.x, piece.position.y, piece.image.size.width, piece.image.size.height); 99 | [animView.layer addSublayer:picLayer]; 100 | [allPicLayers addObject:picLayer]; 101 | } 102 | } 103 | 104 | // add cracks 105 | UIBezierPath *cracksPath = [UIBezierPath bezierPath]; 106 | for (NSInteger r = 0; r < rows; r++) { 107 | for (NSInteger c = 0; c < columns; c++) { 108 | FCImagePiece *piece = pieces[r * columns + c]; 109 | [cracksPath moveToPoint:[piece.corners[0] CGPointValue]]; 110 | [cracksPath addLineToPoint:[piece.corners[1] CGPointValue]]; 111 | [cracksPath addLineToPoint:[piece.corners[2] CGPointValue]]; 112 | [cracksPath addLineToPoint:[piece.corners[3] CGPointValue]]; 113 | [cracksPath addLineToPoint:[piece.corners[0] CGPointValue]]; 114 | } 115 | } 116 | 117 | CAShapeLayer *cracksLayer = [CAShapeLayer layer]; 118 | cracksLayer.frame = animView.bounds; 119 | cracksLayer.path = [cracksPath CGPath]; 120 | cracksLayer.strokeColor = [[UIColor blackColor] CGColor]; 121 | cracksLayer.fillColor = nil; 122 | cracksLayer.lineJoin = kCALineJoinBevel; 123 | [animView.layer addSublayer:cracksLayer]; 124 | 125 | [UIApplication sharedApplication].keyWindow.rootViewController = animController; 126 | 127 | // cracks animation 128 | CABasicAnimation *cracksAnim = [CABasicAnimation animationWithKeyPath:@"lineWidth"]; 129 | cracksAnim.duration = 0.1; 130 | cracksAnim.fillMode = kCAFillModeForwards; 131 | cracksAnim.removedOnCompletion = NO; 132 | cracksAnim.fromValue = @0.0; 133 | cracksAnim.toValue = @2.0; 134 | [cracksLayer addAnimation:cracksAnim forKey:nil]; 135 | 136 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(crackDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 137 | [cracksLayer removeFromSuperlayer]; 138 | }); 139 | 140 | // pieces animation 141 | CGFloat beginTimeMax = 0.1; 142 | CGFloat xMoveMax = animView.bounds.size.width / columns * 0.1; 143 | CGFloat yMove = animView.bounds.size.height * (1.0 + 1.0 / rows); 144 | CGFloat rotateMax = M_PI * 0.1; 145 | CAMediaTimingFunction *timingEaseIn = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; 146 | 147 | for (NSInteger i = 0; i < rows * columns; i++) { 148 | CALayer *picLayer = allPicLayers[i]; 149 | CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform"]; 150 | anim.beginTime = CACurrentMediaTime() + crackDuration + beginTimeMax * randomDouble01(); 151 | anim.duration = fallDuration; 152 | anim.fillMode = kCAFillModeForwards; 153 | anim.cumulative = YES; 154 | anim.removedOnCompletion = NO; 155 | anim.timingFunction = timingEaseIn; 156 | CATransform3D trans = picLayer.transform; 157 | trans = CATransform3DTranslate(trans, randomDouble11() * xMoveMax, yMove, 0); 158 | trans = CATransform3DRotate(trans, randomDouble11() * rotateMax, 0, 0, 1); 159 | anim.toValue = [NSValue valueWithCATransform3D:trans]; 160 | [picLayer addAnimation:anim forKey:nil]; 161 | } 162 | 163 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(totalDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 164 | [self exitApp]; 165 | }); 166 | } 167 | 168 | #pragma mark - Helpers 169 | 170 | - (double)doubleOptionForKey:(NSString *)key defaultValue:(double)defaultValue 171 | { 172 | NSNumber *num = self.effectOptions[key]; 173 | return num ? [num doubleValue] : defaultValue; 174 | } 175 | 176 | - (NSInteger)integerOptionForKey:(NSString *)key defaultValue:(NSInteger)defaultValue 177 | { 178 | NSNumber *num = self.effectOptions[key]; 179 | return num ? [num integerValue] : defaultValue; 180 | } 181 | 182 | - (void)exitApp 183 | { 184 | exit(1); 185 | } 186 | 187 | - (UIImage *)takeScreenshot 188 | { 189 | UIView *rootView = [UIApplication sharedApplication].keyWindow; 190 | UIGraphicsBeginImageContextWithOptions(rootView.bounds.size, NO, [UIScreen mainScreen].scale); 191 | 192 | [rootView drawViewHierarchyInRect:rootView.bounds afterScreenUpdates:YES]; 193 | 194 | UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext(); 195 | UIGraphicsEndImageContext(); 196 | 197 | return screenshot; 198 | } 199 | 200 | - (NSArray *)rectangleSplitImage:(UIImage *)image intoRows:(NSUInteger)rowCount columns:(NSUInteger)colCount { 201 | if (rowCount == 0 || colCount == 0) { 202 | return nil; 203 | } 204 | 205 | NSMutableArray *resultPieces = [NSMutableArray arrayWithCapacity:rowCount * colCount]; 206 | 207 | CGFloat scale = image.scale; 208 | CGFloat blockWidth = image.size.width / colCount; 209 | CGFloat blockHeight = image.size.height / rowCount; 210 | 211 | for (NSUInteger row = 0; row < rowCount; row++) { 212 | for (NSUInteger col = 0; col < colCount; col++) { 213 | CGRect rcBlock = CGRectMake(blockWidth * col, blockHeight * row, blockWidth, blockHeight); 214 | rcBlock = CGRectIntegral(rcBlock); 215 | 216 | FCImagePiece *piece = [FCImagePiece new]; 217 | piece.position = rcBlock.origin; 218 | piece.corners = @[[NSValue valueWithCGPoint:rcBlock.origin], 219 | [NSValue valueWithCGPoint:CGPointMake(rcBlock.origin.x + rcBlock.size.width, rcBlock.origin.y)], 220 | [NSValue valueWithCGPoint:CGPointMake(rcBlock.origin.x + rcBlock.size.width, rcBlock.origin.y + rcBlock.size.height)], 221 | [NSValue valueWithCGPoint:CGPointMake(rcBlock.origin.x, rcBlock.origin.y + rcBlock.size.height)]]; 222 | 223 | rcBlock.origin.x *= scale; 224 | rcBlock.origin.y *= scale; 225 | rcBlock.size.width *= scale; 226 | rcBlock.size.height *= scale; 227 | CGImageRef cgBlock = CGImageCreateWithImageInRect(image.CGImage, rcBlock); 228 | piece.image = [UIImage imageWithCGImage:cgBlock scale:scale orientation:image.imageOrientation]; 229 | CGImageRelease(cgBlock); 230 | 231 | [resultPieces addObject:piece]; 232 | } 233 | } 234 | 235 | return [NSArray arrayWithArray:resultPieces]; 236 | } 237 | 238 | - (NSArray *)polygonSplitImage:(UIImage *)image intoRows:(NSUInteger)rowCount columns:(NSUInteger)colCount { 239 | if (rowCount == 0 || colCount == 0) { 240 | return nil; 241 | } 242 | 243 | NSMutableArray *resultPieces = [NSMutableArray arrayWithCapacity:rowCount * colCount]; 244 | 245 | CGFloat scale = image.scale; 246 | CGFloat blockWidth = image.size.width / colCount; 247 | CGFloat blockHeight = image.size.height / rowCount; 248 | 249 | // random move cell corners 250 | CGPoint *corners = (CGPoint *)malloc(sizeof(CGPoint) * (rowCount + 1) * (colCount + 1)); 251 | CGFloat maxMoveX = blockWidth * 0.3; 252 | CGFloat maxMoveY = blockHeight * 0.3; 253 | for (NSUInteger row = 0; row <= rowCount; row++) { 254 | for (NSUInteger col = 0; col <= colCount; col++) { 255 | CGPoint *pt = corners + row * (colCount + 1) + col; 256 | pt->x = blockWidth * col; 257 | pt->y = blockHeight * row; 258 | if (col != 0 && col != colCount) { 259 | pt->x += randomDouble11() * maxMoveX; 260 | } 261 | if (row != 0 && row != rowCount) { 262 | pt->y += randomDouble11() * maxMoveY; 263 | } 264 | } 265 | } 266 | 267 | for (NSUInteger row = 0; row < rowCount; row++) { 268 | for (NSUInteger col = 0; col < colCount; col++) { 269 | // 4 corners make a polygon 270 | CGPoint *plt = corners + row * (colCount + 1) + col; 271 | CGPoint lt = plt[0]; 272 | CGPoint rt = plt[1]; 273 | CGPoint rb = plt[colCount + 2]; 274 | CGPoint lb = plt[colCount + 1]; 275 | 276 | // bounding rect for sub image 277 | CGFloat minX = MIN(lt.x, lb.x); 278 | CGFloat minY = MIN(lt.y, rt.y); 279 | CGFloat maxX = MAX(rt.x, rb.x); 280 | CGFloat maxY = MAX(lb.y, rb.y); 281 | CGRect rcBlock = CGRectMake(minX, minY, maxX - minX, maxY - minY); 282 | rcBlock = CGRectIntegral(rcBlock); 283 | 284 | FCImagePiece *piece = [FCImagePiece new]; 285 | piece.position = rcBlock.origin; 286 | piece.corners = @[[NSValue valueWithCGPoint:lt], 287 | [NSValue valueWithCGPoint:rt], 288 | [NSValue valueWithCGPoint:rb], 289 | [NSValue valueWithCGPoint:lb]]; 290 | 291 | rcBlock.origin.x *= scale; 292 | rcBlock.origin.y *= scale; 293 | rcBlock.size.width *= scale; 294 | rcBlock.size.height *= scale; 295 | CGImageRef cgBlock = CGImageCreateWithImageInRect(image.CGImage, rcBlock); 296 | 297 | // clip image to polygon 298 | UIBezierPath *clipPath = [UIBezierPath bezierPath]; 299 | [clipPath moveToPoint:lt]; 300 | [clipPath addLineToPoint:rt]; 301 | [clipPath addLineToPoint:rb]; 302 | [clipPath addLineToPoint:lb]; 303 | [clipPath closePath]; 304 | [clipPath applyTransform:CGAffineTransformMakeTranslation(-minX, -minY)]; 305 | [clipPath applyTransform:CGAffineTransformMakeScale(scale, scale)]; 306 | 307 | UIGraphicsBeginImageContextWithOptions(rcBlock.size, NO, 1); 308 | [clipPath addClip]; 309 | [[UIImage imageWithCGImage:cgBlock] drawAtPoint:CGPointZero]; 310 | CGImageRelease(cgBlock); 311 | UIImage *clippedImage = UIGraphicsGetImageFromCurrentImageContext(); 312 | UIGraphicsEndImageContext(); 313 | 314 | piece.image = [UIImage imageWithCGImage:clippedImage.CGImage 315 | scale:scale 316 | orientation:image.imageOrientation]; 317 | 318 | [resultPieces addObject:piece]; 319 | } 320 | } 321 | 322 | free(corners); 323 | 324 | return [NSArray arrayWithArray:resultPieces]; 325 | } 326 | 327 | @end 328 | -------------------------------------------------------------------------------- /FancyCrashTest.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 46D4243A18E31B1000566F46 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 46D4243918E31B1000566F46 /* Foundation.framework */; }; 11 | 46D4243C18E31B1000566F46 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 46D4243B18E31B1000566F46 /* CoreGraphics.framework */; }; 12 | 46D4243E18E31B1000566F46 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 46D4243D18E31B1000566F46 /* UIKit.framework */; }; 13 | 46D4244418E31B1000566F46 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 46D4244218E31B1000566F46 /* InfoPlist.strings */; }; 14 | 46D4244618E31B1000566F46 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 46D4244518E31B1000566F46 /* main.m */; }; 15 | 46D4244A18E31B1000566F46 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 46D4244918E31B1000566F46 /* AppDelegate.m */; }; 16 | 46D4244C18E31B1000566F46 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 46D4244B18E31B1000566F46 /* Images.xcassets */; }; 17 | 46D4246918E31B6800566F46 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 46D4246818E31B6800566F46 /* QuartzCore.framework */; }; 18 | 46D4246D18E31B8A00566F46 /* FancyCrash.m in Sources */ = {isa = PBXBuildFile; fileRef = 46D4246C18E31B8A00566F46 /* FancyCrash.m */; }; 19 | 46D4247018E31DDA00566F46 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 46D4246F18E31DDA00566F46 /* MainViewController.m */; }; 20 | 46D4247218E3210100566F46 /* MainViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 46D4247118E3210100566F46 /* MainViewController.xib */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | 46D4243618E31B1000566F46 /* FancyCrashTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FancyCrashTest.app; sourceTree = BUILT_PRODUCTS_DIR; }; 25 | 46D4243918E31B1000566F46 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 26 | 46D4243B18E31B1000566F46 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 27 | 46D4243D18E31B1000566F46 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 28 | 46D4244118E31B1000566F46 /* FancyCrashTest-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "FancyCrashTest-Info.plist"; sourceTree = ""; }; 29 | 46D4244318E31B1000566F46 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 30 | 46D4244518E31B1000566F46 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 31 | 46D4244718E31B1000566F46 /* FancyCrashTest-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FancyCrashTest-Prefix.pch"; sourceTree = ""; }; 32 | 46D4244818E31B1000566F46 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 33 | 46D4244918E31B1000566F46 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 34 | 46D4244B18E31B1000566F46 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 35 | 46D4246818E31B6800566F46 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 36 | 46D4246B18E31B8A00566F46 /* FancyCrash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FancyCrash.h; sourceTree = ""; }; 37 | 46D4246C18E31B8A00566F46 /* FancyCrash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FancyCrash.m; sourceTree = ""; }; 38 | 46D4246E18E31DDA00566F46 /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = ""; }; 39 | 46D4246F18E31DDA00566F46 /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = ""; }; 40 | 46D4247118E3210100566F46 /* MainViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainViewController.xib; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | 46D4243318E31B1000566F46 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | 46D4246918E31B6800566F46 /* QuartzCore.framework in Frameworks */, 49 | 46D4243C18E31B1000566F46 /* CoreGraphics.framework in Frameworks */, 50 | 46D4243E18E31B1000566F46 /* UIKit.framework in Frameworks */, 51 | 46D4243A18E31B1000566F46 /* Foundation.framework in Frameworks */, 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | 46D4242D18E31B1000566F46 = { 59 | isa = PBXGroup; 60 | children = ( 61 | 46D4246A18E31B7A00566F46 /* FancyCrash */, 62 | 46D4243F18E31B1000566F46 /* FancyCrashTest */, 63 | 46D4243818E31B1000566F46 /* Frameworks */, 64 | 46D4243718E31B1000566F46 /* Products */, 65 | ); 66 | sourceTree = ""; 67 | }; 68 | 46D4243718E31B1000566F46 /* Products */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | 46D4243618E31B1000566F46 /* FancyCrashTest.app */, 72 | ); 73 | name = Products; 74 | sourceTree = ""; 75 | }; 76 | 46D4243818E31B1000566F46 /* Frameworks */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | 46D4246818E31B6800566F46 /* QuartzCore.framework */, 80 | 46D4243918E31B1000566F46 /* Foundation.framework */, 81 | 46D4243B18E31B1000566F46 /* CoreGraphics.framework */, 82 | 46D4243D18E31B1000566F46 /* UIKit.framework */, 83 | ); 84 | name = Frameworks; 85 | sourceTree = ""; 86 | }; 87 | 46D4243F18E31B1000566F46 /* FancyCrashTest */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | 46D4244818E31B1000566F46 /* AppDelegate.h */, 91 | 46D4244918E31B1000566F46 /* AppDelegate.m */, 92 | 46D4246E18E31DDA00566F46 /* MainViewController.h */, 93 | 46D4246F18E31DDA00566F46 /* MainViewController.m */, 94 | 46D4247118E3210100566F46 /* MainViewController.xib */, 95 | 46D4244B18E31B1000566F46 /* Images.xcassets */, 96 | 46D4244018E31B1000566F46 /* Supporting Files */, 97 | ); 98 | path = FancyCrashTest; 99 | sourceTree = ""; 100 | }; 101 | 46D4244018E31B1000566F46 /* Supporting Files */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | 46D4244118E31B1000566F46 /* FancyCrashTest-Info.plist */, 105 | 46D4244218E31B1000566F46 /* InfoPlist.strings */, 106 | 46D4244518E31B1000566F46 /* main.m */, 107 | 46D4244718E31B1000566F46 /* FancyCrashTest-Prefix.pch */, 108 | ); 109 | name = "Supporting Files"; 110 | sourceTree = ""; 111 | }; 112 | 46D4246A18E31B7A00566F46 /* FancyCrash */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 46D4246B18E31B8A00566F46 /* FancyCrash.h */, 116 | 46D4246C18E31B8A00566F46 /* FancyCrash.m */, 117 | ); 118 | path = FancyCrash; 119 | sourceTree = ""; 120 | }; 121 | /* End PBXGroup section */ 122 | 123 | /* Begin PBXNativeTarget section */ 124 | 46D4243518E31B1000566F46 /* FancyCrashTest */ = { 125 | isa = PBXNativeTarget; 126 | buildConfigurationList = 46D4246218E31B1000566F46 /* Build configuration list for PBXNativeTarget "FancyCrashTest" */; 127 | buildPhases = ( 128 | 46D4243218E31B1000566F46 /* Sources */, 129 | 46D4243318E31B1000566F46 /* Frameworks */, 130 | 46D4243418E31B1000566F46 /* Resources */, 131 | ); 132 | buildRules = ( 133 | ); 134 | dependencies = ( 135 | ); 136 | name = FancyCrashTest; 137 | productName = FancyCrashTest; 138 | productReference = 46D4243618E31B1000566F46 /* FancyCrashTest.app */; 139 | productType = "com.apple.product-type.application"; 140 | }; 141 | /* End PBXNativeTarget section */ 142 | 143 | /* Begin PBXProject section */ 144 | 46D4242E18E31B1000566F46 /* Project object */ = { 145 | isa = PBXProject; 146 | attributes = { 147 | LastUpgradeCheck = 0510; 148 | ORGANIZATIONNAME = "Wang Xiaolei"; 149 | }; 150 | buildConfigurationList = 46D4243118E31B1000566F46 /* Build configuration list for PBXProject "FancyCrashTest" */; 151 | compatibilityVersion = "Xcode 3.2"; 152 | developmentRegion = English; 153 | hasScannedForEncodings = 0; 154 | knownRegions = ( 155 | en, 156 | ); 157 | mainGroup = 46D4242D18E31B1000566F46; 158 | productRefGroup = 46D4243718E31B1000566F46 /* Products */; 159 | projectDirPath = ""; 160 | projectRoot = ""; 161 | targets = ( 162 | 46D4243518E31B1000566F46 /* FancyCrashTest */, 163 | ); 164 | }; 165 | /* End PBXProject section */ 166 | 167 | /* Begin PBXResourcesBuildPhase section */ 168 | 46D4243418E31B1000566F46 /* Resources */ = { 169 | isa = PBXResourcesBuildPhase; 170 | buildActionMask = 2147483647; 171 | files = ( 172 | 46D4244418E31B1000566F46 /* InfoPlist.strings in Resources */, 173 | 46D4247218E3210100566F46 /* MainViewController.xib in Resources */, 174 | 46D4244C18E31B1000566F46 /* Images.xcassets in Resources */, 175 | ); 176 | runOnlyForDeploymentPostprocessing = 0; 177 | }; 178 | /* End PBXResourcesBuildPhase section */ 179 | 180 | /* Begin PBXSourcesBuildPhase section */ 181 | 46D4243218E31B1000566F46 /* Sources */ = { 182 | isa = PBXSourcesBuildPhase; 183 | buildActionMask = 2147483647; 184 | files = ( 185 | 46D4244A18E31B1000566F46 /* AppDelegate.m in Sources */, 186 | 46D4246D18E31B8A00566F46 /* FancyCrash.m in Sources */, 187 | 46D4244618E31B1000566F46 /* main.m in Sources */, 188 | 46D4247018E31DDA00566F46 /* MainViewController.m in Sources */, 189 | ); 190 | runOnlyForDeploymentPostprocessing = 0; 191 | }; 192 | /* End PBXSourcesBuildPhase section */ 193 | 194 | /* Begin PBXVariantGroup section */ 195 | 46D4244218E31B1000566F46 /* InfoPlist.strings */ = { 196 | isa = PBXVariantGroup; 197 | children = ( 198 | 46D4244318E31B1000566F46 /* en */, 199 | ); 200 | name = InfoPlist.strings; 201 | sourceTree = ""; 202 | }; 203 | /* End PBXVariantGroup section */ 204 | 205 | /* Begin XCBuildConfiguration section */ 206 | 46D4246018E31B1000566F46 /* Debug */ = { 207 | isa = XCBuildConfiguration; 208 | buildSettings = { 209 | ALWAYS_SEARCH_USER_PATHS = NO; 210 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 211 | CLANG_CXX_LIBRARY = "libc++"; 212 | CLANG_ENABLE_MODULES = YES; 213 | CLANG_ENABLE_OBJC_ARC = YES; 214 | CLANG_WARN_BOOL_CONVERSION = YES; 215 | CLANG_WARN_CONSTANT_CONVERSION = YES; 216 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 217 | CLANG_WARN_EMPTY_BODY = YES; 218 | CLANG_WARN_ENUM_CONVERSION = YES; 219 | CLANG_WARN_INT_CONVERSION = YES; 220 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 221 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 222 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 223 | COPY_PHASE_STRIP = NO; 224 | GCC_C_LANGUAGE_STANDARD = gnu99; 225 | GCC_DYNAMIC_NO_PIC = NO; 226 | GCC_OPTIMIZATION_LEVEL = 0; 227 | GCC_PREPROCESSOR_DEFINITIONS = ( 228 | "DEBUG=1", 229 | "$(inherited)", 230 | ); 231 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 232 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 233 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 234 | GCC_WARN_UNDECLARED_SELECTOR = YES; 235 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 236 | GCC_WARN_UNUSED_FUNCTION = YES; 237 | GCC_WARN_UNUSED_VARIABLE = YES; 238 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 239 | ONLY_ACTIVE_ARCH = YES; 240 | SDKROOT = iphoneos; 241 | TARGETED_DEVICE_FAMILY = "1,2"; 242 | }; 243 | name = Debug; 244 | }; 245 | 46D4246118E31B1000566F46 /* Release */ = { 246 | isa = XCBuildConfiguration; 247 | buildSettings = { 248 | ALWAYS_SEARCH_USER_PATHS = NO; 249 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 250 | CLANG_CXX_LIBRARY = "libc++"; 251 | CLANG_ENABLE_MODULES = YES; 252 | CLANG_ENABLE_OBJC_ARC = YES; 253 | CLANG_WARN_BOOL_CONVERSION = YES; 254 | CLANG_WARN_CONSTANT_CONVERSION = YES; 255 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 256 | CLANG_WARN_EMPTY_BODY = YES; 257 | CLANG_WARN_ENUM_CONVERSION = YES; 258 | CLANG_WARN_INT_CONVERSION = YES; 259 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 260 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 261 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 262 | COPY_PHASE_STRIP = YES; 263 | ENABLE_NS_ASSERTIONS = NO; 264 | GCC_C_LANGUAGE_STANDARD = gnu99; 265 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 266 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 267 | GCC_WARN_UNDECLARED_SELECTOR = YES; 268 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 269 | GCC_WARN_UNUSED_FUNCTION = YES; 270 | GCC_WARN_UNUSED_VARIABLE = YES; 271 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 272 | SDKROOT = iphoneos; 273 | TARGETED_DEVICE_FAMILY = "1,2"; 274 | VALIDATE_PRODUCT = YES; 275 | }; 276 | name = Release; 277 | }; 278 | 46D4246318E31B1000566F46 /* Debug */ = { 279 | isa = XCBuildConfiguration; 280 | buildSettings = { 281 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 282 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 283 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 284 | GCC_PREFIX_HEADER = "FancyCrashTest/FancyCrashTest-Prefix.pch"; 285 | INFOPLIST_FILE = "FancyCrashTest/FancyCrashTest-Info.plist"; 286 | PRODUCT_NAME = "$(TARGET_NAME)"; 287 | WRAPPER_EXTENSION = app; 288 | }; 289 | name = Debug; 290 | }; 291 | 46D4246418E31B1000566F46 /* Release */ = { 292 | isa = XCBuildConfiguration; 293 | buildSettings = { 294 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 295 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 296 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 297 | GCC_PREFIX_HEADER = "FancyCrashTest/FancyCrashTest-Prefix.pch"; 298 | INFOPLIST_FILE = "FancyCrashTest/FancyCrashTest-Info.plist"; 299 | PRODUCT_NAME = "$(TARGET_NAME)"; 300 | WRAPPER_EXTENSION = app; 301 | }; 302 | name = Release; 303 | }; 304 | /* End XCBuildConfiguration section */ 305 | 306 | /* Begin XCConfigurationList section */ 307 | 46D4243118E31B1000566F46 /* Build configuration list for PBXProject "FancyCrashTest" */ = { 308 | isa = XCConfigurationList; 309 | buildConfigurations = ( 310 | 46D4246018E31B1000566F46 /* Debug */, 311 | 46D4246118E31B1000566F46 /* Release */, 312 | ); 313 | defaultConfigurationIsVisible = 0; 314 | defaultConfigurationName = Release; 315 | }; 316 | 46D4246218E31B1000566F46 /* Build configuration list for PBXNativeTarget "FancyCrashTest" */ = { 317 | isa = XCConfigurationList; 318 | buildConfigurations = ( 319 | 46D4246318E31B1000566F46 /* Debug */, 320 | 46D4246418E31B1000566F46 /* Release */, 321 | ); 322 | defaultConfigurationIsVisible = 0; 323 | defaultConfigurationName = Release; 324 | }; 325 | /* End XCConfigurationList section */ 326 | }; 327 | rootObject = 46D4242E18E31B1000566F46 /* Project object */; 328 | } 329 | -------------------------------------------------------------------------------- /FancyCrashTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /FancyCrashTest/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // FancyCrashTest 4 | // 5 | // Created by Wang Xiaolei on 3/26/14. 6 | // Copyright (c) 2014 Wang Xiaolei. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /FancyCrashTest/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // FancyCrashTest 4 | // 5 | // Created by Wang Xiaolei on 3/26/14. 6 | // Copyright (c) 2014 Wang Xiaolei. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "MainViewController.h" 11 | 12 | @implementation AppDelegate 13 | 14 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 15 | { 16 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 17 | // Override point for customization after application launch. 18 | self.window.backgroundColor = [UIColor whiteColor]; 19 | self.window.rootViewController = [MainViewController new]; 20 | [self.window makeKeyAndVisible]; 21 | return YES; 22 | } 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application 25 | { 26 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 27 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 28 | } 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application 31 | { 32 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 33 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 34 | } 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application 37 | { 38 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 39 | } 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application 42 | { 43 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 44 | } 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application 47 | { 48 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /FancyCrashTest/FancyCrashTest-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.wangxl.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /FancyCrashTest/FancyCrashTest-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_3_0 10 | #warning "This project uses features only available in iOS SDK 3.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /FancyCrashTest/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "ipad", 20 | "size" : "29x29", 21 | "scale" : "1x" 22 | }, 23 | { 24 | "idiom" : "ipad", 25 | "size" : "29x29", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "ipad", 30 | "size" : "40x40", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "40x40", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "76x76", 41 | "scale" : "1x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "76x76", 46 | "scale" : "2x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } -------------------------------------------------------------------------------- /FancyCrashTest/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "orientation" : "portrait", 20 | "idiom" : "ipad", 21 | "extent" : "full-screen", 22 | "minimum-system-version" : "7.0", 23 | "scale" : "1x" 24 | }, 25 | { 26 | "orientation" : "landscape", 27 | "idiom" : "ipad", 28 | "extent" : "full-screen", 29 | "minimum-system-version" : "7.0", 30 | "scale" : "1x" 31 | }, 32 | { 33 | "orientation" : "portrait", 34 | "idiom" : "ipad", 35 | "extent" : "full-screen", 36 | "minimum-system-version" : "7.0", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "orientation" : "landscape", 41 | "idiom" : "ipad", 42 | "extent" : "full-screen", 43 | "minimum-system-version" : "7.0", 44 | "scale" : "2x" 45 | } 46 | ], 47 | "info" : { 48 | "version" : 1, 49 | "author" : "xcode" 50 | } 51 | } -------------------------------------------------------------------------------- /FancyCrashTest/Images.xcassets/background.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "background.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x", 11 | "filename" : "background@2x.png" 12 | } 13 | ], 14 | "info" : { 15 | "version" : 1, 16 | "author" : "xcode" 17 | } 18 | } -------------------------------------------------------------------------------- /FancyCrashTest/Images.xcassets/background.imageset/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Quotation/FancyCrash/c4ebd0cf55618ab4059420fae573985734c9add7/FancyCrashTest/Images.xcassets/background.imageset/background.png -------------------------------------------------------------------------------- /FancyCrashTest/Images.xcassets/background.imageset/background@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Quotation/FancyCrash/c4ebd0cf55618ab4059420fae573985734c9add7/FancyCrashTest/Images.xcassets/background.imageset/background@2x.png -------------------------------------------------------------------------------- /FancyCrashTest/MainViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.h 3 | // FancyCrashTest 4 | // 5 | // Created by Wang Xiaolei on 3/26/14. 6 | // Copyright (c) 2014 Wang Xiaolei. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MainViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /FancyCrashTest/MainViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.m 3 | // FancyCrashTest 4 | // 5 | // Created by Wang Xiaolei on 3/26/14. 6 | // Copyright (c) 2014 Wang Xiaolei. All rights reserved. 7 | // 8 | 9 | #import "MainViewController.h" 10 | #import "FancyCrash.h" 11 | 12 | @interface MainViewController () 13 | 14 | @end 15 | 16 | @implementation MainViewController 17 | 18 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 19 | { 20 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 21 | if (self) { 22 | // Custom initialization 23 | } 24 | return self; 25 | } 26 | 27 | - (void)viewDidLoad 28 | { 29 | [super viewDidLoad]; 30 | 31 | self.view.backgroundColor = [UIColor colorWithPatternImage: 32 | [UIImage imageNamed:@"background"]]; 33 | } 34 | 35 | - (void)didReceiveMemoryWarning 36 | { 37 | [super didReceiveMemoryWarning]; 38 | // Dispose of any resources that can be recreated. 39 | } 40 | 41 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 42 | { 43 | // [FancyCrash crash]; 44 | [FancyCrash crashWithEffect:kFancyCrashEffectBreakGlass1 45 | effectOptions:@{/*@"fallDuration": @1.6,*/ @"rows": @8, @"columns": @6}]; 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /FancyCrashTest/MainViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /FancyCrashTest/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /FancyCrashTest/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // FancyCrashTest 4 | // 5 | // Created by Wang Xiaolei on 3/26/14. 6 | // Copyright (c) 2014 Wang Xiaolei. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Xiaolei Wang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | FancyCrash 2 | ========== 3 | 4 | FancyCrash is designed to crash an iOS App with fancy visual effects. 5 | 6 | Silent crash considers not user-friendly. Always give user a FANCY crash effect when possible. 7 | 8 | 9 | Usage 10 | ----- 11 | 12 | Copy `FancyCrash.h` & `.m` to your project. Call `[FancyCrash crash]` to get a random crash effect. Or use `[FancyCrash crashWithEffect:effectOptions:]` to customize the crash animation. 13 | 14 | 15 | Customize Effects 16 | ------- 17 | 18 | Options for `kFancyCrashEffectBreakGlass1`: 19 | 20 | ``` 21 | @{ 22 | @"crackDuration" : @0.5, // crack animation duration 23 | @"fallDuration" : @0.9, // fall animation duration 24 | @"rows" : @6, // row count 25 | @"columns" : @4, // column count 26 | } 27 | ``` --------------------------------------------------------------------------------