├── DaiInboxHUD ├── Default-568h@2x.png ├── MainViewController.h ├── AppDelegate.h ├── main.m ├── DaiInboxHUD │ ├── DaiInboxView.h │ ├── UIColor+MixColor.h │ ├── DaiIndoxWindow.h │ ├── DaiDrawPathView.h │ ├── DaiIndoxWindow.m │ ├── DaiInboxDisplayLink.h │ ├── DaiInboxViewController.h │ ├── UIColor+MixColor.m │ ├── DaiInboxDisplayLink.m │ ├── DaiInboxHUD.h │ ├── DaiDrawPathView.m │ ├── DaiInboxHUD.m │ ├── DaiInboxView.m │ └── DaiInboxViewController.m ├── AppDelegate.m ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── MainViewController.xib └── MainViewController.m ├── DaiInboxHUD.xcodeproj ├── project.xcworkspace │ └── contents.xcworkspacedata ├── xcuserdata │ └── ChilunChen.xcuserdatad │ │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ └── DaiInboxHUD.xcscheme └── project.pbxproj ├── DaiInboxHUDTests ├── Info.plist └── DaiInboxHUDTests.m ├── .gitignore └── README.md /DaiInboxHUD/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DaidoujiChen/DaiInboxHUD/HEAD/DaiInboxHUD/Default-568h@2x.png -------------------------------------------------------------------------------- /DaiInboxHUD.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DaiInboxHUD/MainViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.h 3 | // DaiInboxHUD 4 | // 5 | // Created by 啟倫 陳 on 2014/10/31. 6 | // Copyright (c) 2014年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "DaiInboxView.h" 12 | 13 | @interface MainViewController : UIViewController 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /DaiInboxHUD/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // DaiInboxHUD 4 | // 5 | // Created by 啟倫 陳 on 2014/10/31. 6 | // Copyright (c) 2014年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "MainViewController.h" 12 | 13 | @interface AppDelegate : UIResponder 14 | 15 | @property (strong, nonatomic) UIWindow *window; 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /DaiInboxHUD/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // DaiInboxHUD 4 | // 5 | // Created by 啟倫 陳 on 2014/10/31. 6 | // Copyright (c) 2014年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /DaiInboxHUD/DaiInboxHUD/DaiInboxView.h: -------------------------------------------------------------------------------- 1 | // 2 | // DaiInboxView.h 3 | // DaiInboxHUD 4 | // 5 | // Created by 啟倫 陳 on 2014/10/31. 6 | // Copyright (c) 2014年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "DaiInboxDisplayLink.h" 11 | 12 | @interface DaiInboxView : UIView 13 | 14 | @property (nonatomic, strong) NSArray *hudColors; 15 | @property (nonatomic, assign) CGFloat hudLineWidth; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /DaiInboxHUD/DaiInboxHUD/UIColor+MixColor.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+MixColor.h 3 | // DaiInboxHUD 4 | // 5 | // Created by DaidoujiChen on 2015/8/11. 6 | // Copyright (c) 2015年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIColor (MixColor) 12 | 13 | @property (nonatomic, readonly) CGFloat r; 14 | @property (nonatomic, readonly) CGFloat g; 15 | @property (nonatomic, readonly) CGFloat b; 16 | @property (nonatomic, readonly) CGFloat a; 17 | 18 | - (UIColor *)mixColor:(UIColor *)otherColor; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /DaiInboxHUD/DaiInboxHUD/DaiIndoxWindow.h: -------------------------------------------------------------------------------- 1 | // 2 | // DaiIndoxWindow.h 3 | // DaiInboxHUD 4 | // 5 | // Created by 啟倫 陳 on 2014/11/4. 6 | // Copyright (c) 2014年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol DaiIndoxWindowDelegate; 12 | 13 | @interface DaiIndoxWindow : UIWindow 14 | 15 | @property (nonatomic, weak) id eventDelegate; 16 | 17 | @end 18 | 19 | @protocol DaiIndoxWindowDelegate 20 | @required 21 | - (BOOL)shouldHandleTouchAtPoint:(CGPoint)point; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /DaiInboxHUD/DaiInboxHUD/DaiDrawPathView.h: -------------------------------------------------------------------------------- 1 | // 2 | // DaiDrawPathView.h 3 | // DaiInboxHUD 4 | // 5 | // Created by DaidoujiChen on 2015/8/13. 6 | // Copyright (c) 2015年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "DaiInboxDisplayLink.h" 11 | 12 | @interface DaiDrawPathView : UIView 13 | 14 | @property (nonatomic, strong) UIColor *pathColor; 15 | @property (nonatomic, strong) NSArray *drawPath; 16 | @property (nonatomic, assign) CGFloat lengthIteration; 17 | @property (nonatomic, assign) CGFloat hudLineWidth; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /DaiInboxHUD/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // DaiInboxHUD 4 | // 5 | // Created by 啟倫 陳 on 2014/10/31. 6 | // Copyright (c) 2014年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 18 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 19 | self.window.rootViewController = [MainViewController new]; 20 | [self.window makeKeyAndVisible]; 21 | return YES; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /DaiInboxHUD.xcodeproj/xcuserdata/ChilunChen.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | DaiInboxHUD.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 0131ED321A037767001C0DD8 16 | 17 | primary 18 | 19 | 20 | 0131ED4B1A037767001C0DD8 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /DaiInboxHUD/DaiInboxHUD/DaiIndoxWindow.m: -------------------------------------------------------------------------------- 1 | // 2 | // DaiIndoxWindow.m 3 | // DaiInboxHUD 4 | // 5 | // Created by 啟倫 陳 on 2014/11/4. 6 | // Copyright (c) 2014年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import "DaiIndoxWindow.h" 10 | 11 | @implementation DaiIndoxWindow 12 | 13 | #pragma mark - method to override 14 | 15 | - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { 16 | return [self.eventDelegate shouldHandleTouchAtPoint:point]; 17 | } 18 | 19 | #pragma mark - life cycle 20 | 21 | - (id)initWithFrame:(CGRect)frame { 22 | self = [super initWithFrame:frame]; 23 | if (self) { 24 | self.backgroundColor = [UIColor clearColor]; 25 | self.windowLevel = UIWindowLevelAlert - 1; 26 | } 27 | return self; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /DaiInboxHUD/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" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /DaiInboxHUDTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | tw.tyche.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /DaiInboxHUD/DaiInboxHUD/DaiInboxDisplayLink.h: -------------------------------------------------------------------------------- 1 | // 2 | // DaiInboxDisplayLink.h 3 | // DaiInboxHUD 4 | // 5 | // Created by 啟倫 陳 on 2014/11/7. 6 | // Copyright (c) 2014年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | //idea from http://www.paulwrightapps.com/blog/2014/8/20/creating-smooth-frame-by-frame-animations-on-ios-based-on-the-time-passed-between-frames 13 | 14 | @protocol DaiInboxDisplayLinkDelegate; 15 | 16 | @interface DaiInboxDisplayLink : NSObject 17 | 18 | @property (nonatomic, weak) id delegate; 19 | 20 | - (id)initWithDelegate:(id )delegate; 21 | - (void)removeDisplayLink; 22 | 23 | @end 24 | 25 | @protocol DaiInboxDisplayLinkDelegate 26 | 27 | @required 28 | - (void)displayWillUpdateWithDeltaTime:(CFTimeInterval)deltaTime; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /DaiInboxHUD/DaiInboxHUD/DaiInboxViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DaiInboxViewController.h 3 | // DaiInboxHUD 4 | // 5 | // Created by 啟倫 陳 on 2014/11/4. 6 | // Copyright (c) 2014年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef enum { 12 | DaiInboxHUDTypeDefault, 13 | DaiInboxHUDTypeSuccess, 14 | DaiInboxHUDTypeFail 15 | } DaiInboxHUDType; 16 | 17 | @interface DaiInboxViewController : UIViewController 18 | 19 | @property (nonatomic, strong) NSArray *colors; 20 | @property (nonatomic, strong) UIColor *backgroundColor; 21 | @property (nonatomic, strong) UIColor *maskColor; 22 | @property (nonatomic, strong) UIColor *checkmarkColor; 23 | @property (nonatomic, strong) UIColor *crossColor; 24 | @property (nonatomic, assign) CGFloat lineWidth; 25 | @property (nonatomic, strong) NSAttributedString *message; 26 | @property (nonatomic, assign) BOOL allowUserInteraction; 27 | @property (nonatomic, assign) DaiInboxHUDType type; 28 | 29 | - (void)hide:(void (^)(void))completion; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /DaiInboxHUDTests/DaiInboxHUDTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // DaiInboxHUDTests.m 3 | // DaiInboxHUDTests 4 | // 5 | // Created by 啟倫 陳 on 2014/10/31. 6 | // Copyright (c) 2014年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface DaiInboxHUDTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation DaiInboxHUDTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /DaiInboxHUD/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | tw.tyche.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io 2 | 3 | ### Xcode ### 4 | build/ 5 | *.pbxuser 6 | !default.pbxuser 7 | *.mode1v3 8 | !default.mode1v3 9 | *.mode2v3 10 | !default.mode2v3 11 | *.perspectivev3 12 | !default.perspectivev3 13 | xcuserdata 14 | *.xccheckout 15 | *.moved-aside 16 | DerivedData 17 | *.xcuserstate 18 | 19 | 20 | ### OSX ### 21 | .DS_Store 22 | .AppleDouble 23 | .LSOverride 24 | 25 | # Icon must end with two \r 26 | Icon 27 | 28 | 29 | # Thumbnails 30 | ._* 31 | 32 | # Files that might appear on external disk 33 | .Spotlight-V100 34 | .Trashes 35 | 36 | # Directories potentially created on remote AFP share 37 | .AppleDB 38 | .AppleDesktop 39 | Network Trash Folder 40 | Temporary Items 41 | .apdisk 42 | 43 | 44 | ### Objective-C ### 45 | # Xcode 46 | # 47 | build/ 48 | *.pbxuser 49 | !default.pbxuser 50 | *.mode1v3 51 | !default.mode1v3 52 | *.mode2v3 53 | !default.mode2v3 54 | *.perspectivev3 55 | !default.perspectivev3 56 | xcuserdata 57 | *.xccheckout 58 | *.moved-aside 59 | DerivedData 60 | *.hmap 61 | *.ipa 62 | *.xcuserstate 63 | 64 | # CocoaPods 65 | # 66 | # We recommend against adding the Pods directory to your .gitignore. However 67 | # you should judge for yourself, the pros and cons are mentioned at: 68 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 69 | # 70 | # Pods/ 71 | -------------------------------------------------------------------------------- /DaiInboxHUD/DaiInboxHUD/UIColor+MixColor.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+MixColor.m 3 | // DaiInboxHUD 4 | // 5 | // Created by DaidoujiChen on 2015/8/11. 6 | // Copyright (c) 2015年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import "UIColor+MixColor.h" 10 | #import 11 | 12 | @implementation UIColor (MixColor) 13 | 14 | @dynamic r, g, b, a; 15 | 16 | - (CGFloat)r { 17 | return [[self rgba][@"r"] floatValue]; 18 | } 19 | 20 | - (CGFloat)g { 21 | return [[self rgba][@"g"] floatValue]; 22 | } 23 | 24 | - (CGFloat)b { 25 | return [[self rgba][@"b"] floatValue]; 26 | } 27 | 28 | - (CGFloat)a { 29 | return [[self rgba][@"a"] floatValue]; 30 | } 31 | 32 | - (UIColor *)mixColor:(UIColor *)otherColor { 33 | //混色的公式 34 | //http://stackoverflow.com/questions/726549/algorithm-for-additive-color-mixing-for-rgb-values 35 | CGFloat newAlpha = 1 - (1 - self.a) * (1 - otherColor.a); 36 | CGFloat newRed = self.r * self.a / newAlpha + otherColor.r * otherColor.a * (1 - self.a) / newAlpha; 37 | CGFloat newGreen = self.g * self.a / newAlpha + otherColor.g * otherColor.a * (1 - self.a) / newAlpha; 38 | CGFloat newBlue = self.b * self.a / newAlpha + otherColor.b * otherColor.a * (1 - self.a) / newAlpha; 39 | return [UIColor colorWithRed:newRed green:newGreen blue:newBlue alpha:newAlpha]; 40 | } 41 | 42 | - (NSDictionary *)rgba { 43 | NSDictionary *rgba = objc_getAssociatedObject(self, _cmd); 44 | if (!rgba) { 45 | CGFloat red = 0.0f, green = 0.0f, blue = 0.0f, alpha = 0.0f; 46 | if ([self getRed:&red green:&green blue:&blue alpha:&alpha]) { 47 | [self setRgba:@{ @"r":@(red), @"g":@(green), @"b":@(blue), @"a":@(alpha) }]; 48 | } 49 | else { 50 | //http://stackoverflow.com/questions/4700168/get-rgb-value-from-uicolor-presets 51 | CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB(); 52 | unsigned char resultingPixel[3]; 53 | CGContextRef context = CGBitmapContextCreate(&resultingPixel, 1, 1, 8, 4, rgbColorSpace, (CGBitmapInfo)kCGImageAlphaNone); 54 | CGContextSetFillColorWithColor(context, [self CGColor]); 55 | CGContextFillRect(context, CGRectMake(0, 0, 1, 1)); 56 | CGContextRelease(context); 57 | CGColorSpaceRelease(rgbColorSpace); 58 | [self setRgba:@{ @"r":@(resultingPixel[0]), @"g":@(resultingPixel[1]), @"b":@(resultingPixel[2]), @"a":@(1.0f) }]; 59 | } 60 | } 61 | return objc_getAssociatedObject(self, _cmd); 62 | } 63 | 64 | - (void)setRgba:(NSDictionary *)rgba { 65 | objc_setAssociatedObject(self, @selector(rgba), rgba, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /DaiInboxHUD/DaiInboxHUD/DaiInboxDisplayLink.m: -------------------------------------------------------------------------------- 1 | // 2 | // DaiInboxDisplayLink.m 3 | // DaiInboxHUD 4 | // 5 | // Created by 啟倫 陳 on 2014/11/7. 6 | // Copyright (c) 2014年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import "DaiInboxDisplayLink.h" 10 | 11 | @interface DaiInboxDisplayLink () 12 | 13 | @property (nonatomic, strong) CADisplayLink *displayLink; 14 | @property (nonatomic, assign) BOOL nextDeltaTimeZero; 15 | @property (nonatomic, assign) CFTimeInterval previousTimestamp; 16 | 17 | @end 18 | 19 | @implementation DaiInboxDisplayLink 20 | 21 | #pragma mark - instance method 22 | 23 | - (void)removeDisplayLink { 24 | //移除 displaylink 25 | [self.displayLink invalidate]; 26 | 27 | //移除掉監聽 28 | [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil]; 29 | [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillResignActiveNotification object:nil]; 30 | } 31 | 32 | #pragma mark - private 33 | 34 | - (void)setupDisplayLink { 35 | //建立 displaylink 36 | self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(displayLinkUpdated)]; 37 | [self.displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; 38 | 39 | //監聽兩個 notification 40 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActiveNotification) name:UIApplicationDidBecomeActiveNotification object:nil]; 41 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillResignActiveNotification) name:UIApplicationWillResignActiveNotification object:nil]; 42 | } 43 | 44 | //當畫面的 frame 有變動時, 會進到這個地方 45 | - (void)displayLinkUpdated { 46 | //用時間戳記算出兩個 frame 的間隔時間 47 | CFTimeInterval currentTime = self.displayLink.timestamp; 48 | CFTimeInterval deltaTime; 49 | if (self.nextDeltaTimeZero) { 50 | self.nextDeltaTimeZero = NO; 51 | deltaTime = 0.0; 52 | } 53 | else { 54 | deltaTime = currentTime - self.previousTimestamp; 55 | } 56 | self.previousTimestamp = currentTime; 57 | 58 | //把這個數值用 delegate 帶回去 59 | [self.delegate displayWillUpdateWithDeltaTime:deltaTime]; 60 | } 61 | 62 | //如果 app 要回來前景了, displaylink 則啟動 63 | - (void)applicationDidBecomeActiveNotification { 64 | self.displayLink.paused = NO; 65 | self.nextDeltaTimeZero = YES; 66 | } 67 | 68 | //反之則暫停 69 | - (void)applicationWillResignActiveNotification { 70 | self.displayLink.paused = YES; 71 | self.nextDeltaTimeZero = YES; 72 | } 73 | 74 | #pragma mark - life cycle 75 | 76 | - (id)initWithDelegate:(id )delegate { 77 | self = [super init]; 78 | if (self) { 79 | self.delegate = delegate; 80 | self.nextDeltaTimeZero = YES; 81 | self.previousTimestamp = 0; 82 | [self setupDisplayLink]; 83 | } 84 | return self; 85 | } 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /DaiInboxHUD/MainViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 27 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /DaiInboxHUD/DaiInboxHUD/DaiInboxHUD.h: -------------------------------------------------------------------------------- 1 | // 2 | // DaiInboxHUD.h 3 | // DaiInboxHUD 4 | // 5 | // Created by 啟倫 陳 on 2014/10/31. 6 | // Copyright (c) 2014年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class DaiInboxHUD; 13 | typedef DaiInboxHUD *(^CopiedHUD)(DaiInboxHUD *copiedHUD); 14 | 15 | @interface DaiInboxHUD : NSObject 16 | 17 | //設定自己想要的顏色循環, 預設是 紅 -> 綠 -> 黃 -> 藍 -> loop, 起始為哪一個則為隨機, 建議設定兩個顏色以上 18 | @property (nonatomic, strong) NSArray *colors; 19 | 20 | //設定打勾勾顏色, 預設為純綠 21 | @property (nonatomic, strong) UIColor *checkmarkColor; 22 | 23 | //設定叉叉顏色, 預設為純紅 24 | @property (nonatomic, strong) UIColor *crossColor; 25 | 26 | //設定 hud 的背景顏色, 預設為 0.65 alpha 的黑色 27 | @property (nonatomic, strong) UIColor *backgroundColor; 28 | 29 | //設定 hud 跳出來時, 原來的畫面要用什麼顏色蓋住, 預設蓋住的顏色是 clearColor 30 | @property (nonatomic, strong) UIColor *maskColor; 31 | 32 | //設定 hud 轉圈圈線的粗細, 預設為 2.0f, 數值大約到 10.0f 都還可以看, 到 20.0f 就不知道在幹嘛了 33 | @property (nonatomic, assign) CGFloat lineWidth; 34 | 35 | //切換在 hud 過程中, 使用者是否可以有其他動作, 預設為 NO, 不允許 36 | @property (nonatomic, assign) BOOL allowUserInteraction; 37 | 38 | //顯示轉圈 hud, 可帶字, 可設定幾秒後消失 39 | + (void)show; 40 | + (void)showThenHideAfterDelay:(NSTimeInterval)delay; 41 | + (void)showMessage:(NSAttributedString *)message; 42 | + (void)showMessage:(NSAttributedString *)message hideAfterDelay:(NSTimeInterval)delay; 43 | + (void)showCopied:(CopiedHUD)copied; 44 | + (void)showCopied:(CopiedHUD)copied thenHideAfterDelay:(NSTimeInterval)delay; 45 | + (void)showCopied:(CopiedHUD)copied andMessage:(NSAttributedString *)message; 46 | + (void)showCopied:(CopiedHUD)copied andMessage:(NSAttributedString *)message hideAfterDelay:(NSTimeInterval)delay; 47 | 48 | //顯示成功動畫, 可帶字, 可設定幾秒後消失 49 | + (void)showSuccess; 50 | + (void)showSuccessThenHideAfterDelay:(NSTimeInterval)delay; 51 | + (void)showSuccessMessage:(NSAttributedString *)message; 52 | + (void)showSuccessMessage:(NSAttributedString *)message hideAfterDelay:(NSTimeInterval)delay; 53 | + (void)showSuccessCopied:(CopiedHUD)copied; 54 | + (void)showSuccessCopied:(CopiedHUD)copied thenHideAfterDelay:(NSTimeInterval)delay; 55 | + (void)showSuccessCopied:(CopiedHUD)copied andMessage:(NSAttributedString *)message; 56 | + (void)showSuccessCopied:(CopiedHUD)copied andMessage:(NSAttributedString *)message hideAfterDelay:(NSTimeInterval)delay; 57 | 58 | //顯示失敗動畫, 可帶字, 可設定幾秒後消失 59 | + (void)showFail; 60 | + (void)showFailThenHideAfterDelay:(NSTimeInterval)delay; 61 | + (void)showFailMessage:(NSAttributedString *)message; 62 | + (void)showFailMessage:(NSAttributedString *)message hideAfterDelay:(NSTimeInterval)delay; 63 | + (void)showFailCopied:(CopiedHUD)copied; 64 | + (void)showFailCopied:(CopiedHUD)copied thenHideAfterDelay:(NSTimeInterval)delay; 65 | + (void)showFailCopied:(CopiedHUD)copied andMessage:(NSAttributedString *)message; 66 | + (void)showFailCopied:(CopiedHUD)copied andMessage:(NSAttributedString *)message hideAfterDelay:(NSTimeInterval)delay; 67 | 68 | //隱藏 hud,可設定幾秒後消失 69 | + (void)hide; 70 | + (void)hideAfterDelay:(NSTimeInterval)delay; 71 | 72 | //共用實例 73 | + (DaiInboxHUD *)shared; 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /DaiInboxHUD/MainViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.m 3 | // DaiInboxHUD 4 | // 5 | // Created by 啟倫 陳 on 2014/10/31. 6 | // Copyright (c) 2014年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import "MainViewController.h" 10 | 11 | #import "DaiInboxHUD.h" 12 | 13 | @interface MainViewController () 14 | 15 | @end 16 | 17 | @implementation MainViewController 18 | 19 | #pragma mark - ibaction 20 | 21 | - (IBAction)showAction:(id)sender { 22 | UIFont *font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline]; 23 | UIColor *textColor = [UIColor blackColor]; 24 | NSDictionary *attributes = @{ NSForegroundColorAttributeName : textColor, NSFontAttributeName : font, NSTextEffectAttributeName : NSTextEffectLetterpressStyle }; 25 | NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:@"Loading" attributes:attributes]; 26 | 27 | switch (arc4random() % 3) { 28 | case 0: 29 | if (arc4random() % 2) { 30 | [DaiInboxHUD showMessage:attributedString hideAfterDelay:2.0f]; 31 | } 32 | else { 33 | [DaiInboxHUD showCopied: ^DaiInboxHUD *(DaiInboxHUD *copiedHUD) { 34 | copiedHUD.backgroundColor = [UIColor redColor]; 35 | return copiedHUD; 36 | } andMessage:attributedString hideAfterDelay:2.0f]; 37 | } 38 | break; 39 | 40 | case 1: 41 | if (arc4random() % 2) { 42 | [DaiInboxHUD showSuccessMessage:attributedString hideAfterDelay:3.0f]; 43 | } 44 | else { 45 | [DaiInboxHUD showSuccessCopied: ^DaiInboxHUD *(DaiInboxHUD *copiedHUD) { 46 | copiedHUD.checkmarkColor = [UIColor blueColor]; 47 | return copiedHUD; 48 | } andMessage:attributedString hideAfterDelay:3.0f]; 49 | } 50 | break; 51 | 52 | case 2: 53 | if (arc4random() % 2) { 54 | [DaiInboxHUD showFailMessage:attributedString hideAfterDelay:4.0f]; 55 | } 56 | else { 57 | [DaiInboxHUD showFailCopied: ^DaiInboxHUD *(DaiInboxHUD *copiedHUD) { 58 | copiedHUD.crossColor = [UIColor purpleColor]; 59 | copiedHUD.allowUserInteraction = YES; 60 | return copiedHUD; 61 | } andMessage:attributedString hideAfterDelay:4.0f]; 62 | } 63 | break; 64 | 65 | default: 66 | break; 67 | } 68 | } 69 | 70 | - (IBAction)clickAction:(id)sender { 71 | NSLog(@"Clicked"); 72 | } 73 | 74 | #pragma mark - life cycle 75 | 76 | - (void)viewDidLoad { 77 | [super viewDidLoad]; 78 | 79 | //客製化想要的顏色 80 | [DaiInboxHUD shared].colors = @[[UIColor grayColor], [UIColor whiteColor], [UIColor blackColor], [UIColor purpleColor]]; 81 | 82 | //想要的背景色 83 | [DaiInboxHUD shared].backgroundColor = [UIColor orangeColor]; 84 | 85 | //想要的遮膜色 86 | [DaiInboxHUD shared].maskColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5f]; 87 | 88 | //想要的線條粗度 89 | [DaiInboxHUD shared].lineWidth = 4.0f; 90 | 91 | //打勾要顯示的顏色 92 | [DaiInboxHUD shared].checkmarkColor = [UIColor greenColor]; 93 | 94 | //叉叉要顯示的顏色 95 | [DaiInboxHUD shared].crossColor = [UIColor redColor]; 96 | 97 | //當然也都可以不設, 使用預設帶的值 98 | } 99 | 100 | @end 101 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DaiInboxHUD 2 | =========== 3 | 4 | 這是一個模仿 google inbox 轉圈效果的 HUD. 5 | 6 | ![image](https://s3-ap-northeast-1.amazonaws.com/daidoujiminecraft/Daidouji/DaiInboxHUD_20141106.gif) 7 | 8 | 加入成功時候打勾的動畫 9 | 10 | ![image](https://s3-ap-northeast-1.amazonaws.com/daidoujiminecraft/Daidouji/DaiInboxHUDSuccess.gif) 11 | 12 | 失敗時候畫叉叉的動畫 13 | 14 | ![image](https://s3-ap-northeast-1.amazonaws.com/daidoujiminecraft/Daidouji/DaiInboxHUDFail.gif) 15 | 16 | DaidoujiChen 17 | 18 | daidoujichen@gmail.com 19 | 20 | 總覽 21 | =========== 22 | 長久以來我就蠻想要一個自己做的 HUD 用, 前幾天幸運的從 g+ 善心人士 [宇治松千夜](https://plus.google.com/u/0/+%E6%88%B4%E6%B5%B7%E5%88%9A%E4%B8%AD%E5%9B%BD/auto) 這邊拿到了一組 inbox 邀請碼, 裝了 app 之後覺得他裡面的轉圈效果很棒, 所以花了幾天的時間, 儘量的模仿了他的效果, 未來可以給自己的其他專案使用. 23 | 24 | 簡易使用 25 | =========== 26 | 先把 `DaiInboxHUD` 資料夾下的東西 copy 一份到你想用他的專案中, 然後在想使用他的地方先 27 | 28 | ````` 29 | #import "DaiInboxHUD.h" 30 | ````` 31 | 32 | 然後就算是可以使用了, 當要叫 HUD 出來的時候 call 33 | 34 | ````` 35 | [DaiInboxHUD show]; 36 | ````` 37 | 38 | 如果想要秀帶訊息的 hud 可以調用 39 | 40 | ````` 41 | [DaiInboxHUD showMessage:[[NSAttributedString alloc] initWithString:@"Loading"]]; 42 | ````` 43 | 44 | 在這邊 message 的型別是 `NSAttributedString`, 這意味著你可以調整你想要的字型或是大小, 或是任何符合規定的效果, 比起 `NSString` 的話, 我認為靈活度會比較大, 另外還有表示成功的 45 | 46 | ````` 47 | + (void)showSuccess; 48 | + (void)showSuccessMessage:(NSAttributedString *)message; 49 | ````` 50 | 51 | 與表示失敗的 52 | 53 | ````` 54 | + (void)showFail; 55 | + (void)showFailMessage:(NSAttributedString *)message; 56 | ````` 57 | 58 | 要他消失的時候 call 59 | 60 | ````` 61 | [DaiInboxHUD hide]; 62 | [DaiInboxHUD hideAfterDelay:2.0f]; 63 | ````` 64 | 65 | `hideAfterDelay:` 可以設置在幾秒後消失, 也可以添加於上面任何一個 method 的後面. 66 | 67 | 客製化 68 | =========== 69 | 如果你覺得內建的顏色很醜, 想要用自己調配的顏色, 或是想要跟自己的專案色調搭配一點的話, 這邊提供了幾種客製化的 method, 70 | 71 | ##內容色 72 | 73 | ````` 74 | + (void)setColors:(NSArray *)colors; 75 | ````` 76 | 77 | 這個 method 可以幫助你改變循環的顏色, 內建本來是 紅 -> 綠 -> 黃 -> 藍 -> loop 這樣的循環, 起始顏色則為隨機, 如果想改變的話, 可以調用 78 | 79 | ````` 80 | [DaiInboxHUD setColors:@[[UIColor grayColor], [UIColor whiteColor], [UIColor blackColor], [UIColor purpleColor]]]; 81 | ````` 82 | 83 | 以這個例子來說, 循環色將會被改變成 灰 -> 白 -> 黑 -> 紫 -> loop, 84 | 85 | ````` 86 | + (void)setCheckmarkColor:(UIColor *)checkmarkColor; 87 | ````` 88 | 89 | `checkmarkColor` 改變的是勾勾的顏色, 預設為純綠, 90 | 91 | ````` 92 | + (void)setCrossColor:(UIColor *)crossColor; 93 | ````` 94 | 95 | `crossColor` 改變的是叉叉的顏色, 預設為純紅 96 | 97 | ##HUD背景色 98 | 99 | ````` 100 | + (void)setBackgroundColor:(UIColor *)backgroundColor; 101 | ````` 102 | 103 | 這個 method 可以幫助你改變 hud 背後那一小塊的顏色, 系統預設為 0.65 alpha 的黑色, 是的, 請記得 `UIColor` 可以設 alpha, 有助於幫助在專案上的搭配, 可以調用 104 | 105 | ````` 106 | [DaiInboxHUD setBackgroundColor:[UIColor colorWithRed:0.43f green:0.12f blue:0.95f alpha:0.4f]]; 107 | ````` 108 | 109 | 來做背景色的改變, 數字是我亂打的, 我也不知道出來會是什麼色, 110 | 111 | ````` 112 | + (void)setMaskColor:(UIColor *)maskColor; 113 | ````` 114 | 115 | 如果你希望 hud 跳出來的時候, 背後原來的畫面應該要覆蓋上一層薄膜, 可以利用這個 method 來達成, 預設是 clearColor, 所以背景不會被覆蓋, 如果想用一層黑色的膜蓋上, 可以像是這樣設定 116 | 117 | ````` 118 | [DaiInboxHUD setMaskColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:0.5f]]; 119 | ````` 120 | 121 | 則會有一層 alpha 值 0.5 的黑膜蓋著, 記得一定要設 alpha, 不然背景會完全被蓋住, 122 | 123 | ##線條粗細 124 | 125 | ````` 126 | + (void)setLineWidth:(CGFloat)lineWidth; 127 | ````` 128 | 129 | 顧名思義, 他就是用來改線條的粗細, 如果你覺得內建的線太細, 很容易折斷或是老人家看不清楚, 可以透過這個 method 來做改變, 預設的寬度只有 2.0f 130 | 131 | ````` 132 | [DaiInboxHUD setLineWidth:10.0f]; 133 | ````` 134 | 135 | 改成 10.0f 的時候線會變得胖胖的, 很可愛, 但是再往上加畫出來的圖就會有些怪怪的了, 這邊可以自己斟酌微調, 136 | 137 | ##完全遮蔽 138 | 139 | ````` 140 | + (void)allowUserInteraction:(BOOL)allowUserInteraction; 141 | ````` 142 | 143 | 當把這個設定填為 `YES` 時, 在 hud 顯示時, 背後的功能還是可以被操作, 當填 `NO` 的時候, 則會阻斷所有事件. 144 | 145 | ##特例 146 | 有些時候會想要出現單次設定不同於上面所有設置的行為, 比方說某些時候 hud 顏色特別想跟別人不一樣或是某些 hud 可以允許使用者觸控, 這時候可以用 `copied` 類的 method, 147 | 148 | ````` 149 | + (void)showCopied:(CopiedHUD)copied; 150 | ````` 151 | 152 | 在這個方法下, 我們可以使用與原來設定完全相同的 hud, 只更動其中幾項設置, 而在這個 hud 之後, 不影響到其他 hud 153 | 154 | ````` 155 | [DaiInboxHUD showCopied: ^DaiInboxHUD *(DaiInboxHUD *copiedHUD) { 156 | copiedHUD.backgroundColor = [UIColor blackColor]; 157 | return copiedHUD; 158 | }]; 159 | ````` -------------------------------------------------------------------------------- /DaiInboxHUD/DaiInboxHUD/DaiDrawPathView.m: -------------------------------------------------------------------------------- 1 | // 2 | // DaiDrawPathView.m 3 | // DaiInboxHUD 4 | // 5 | // Created by DaidoujiChen on 2015/8/13. 6 | // Copyright (c) 2015年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import "DaiDrawPathView.h" 10 | #import "UIColor+MixColor.h" 11 | 12 | #define framePerSecond 60.0f 13 | 14 | @interface DaiDrawPathView () 15 | 16 | @property (nonatomic, assign) CGFloat length; 17 | @property (nonatomic, strong) DaiInboxDisplayLink *displayLink; 18 | @property (nonatomic, strong) UIImage *pathImage; 19 | 20 | @end 21 | 22 | @implementation DaiDrawPathView 23 | 24 | #pragma mark - DaiInboxDisplayLinkDelegate 25 | 26 | - (void)displayWillUpdateWithDeltaTime:(CFTimeInterval)deltaTime { 27 | __weak DaiDrawPathView *weakSelf = self; 28 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 29 | if (weakSelf) { 30 | __strong DaiDrawPathView *strongSelf = weakSelf; 31 | CGFloat deltaValue = MIN(1.0f, deltaTime / (1.0f / framePerSecond)); 32 | strongSelf.length += self.lengthIteration * deltaValue; 33 | strongSelf.pathImage = [strongSelf preDrawPathImage]; 34 | 35 | //算完以後回 main thread 囉 36 | dispatch_async(dispatch_get_main_queue(), ^{ 37 | [strongSelf setNeedsDisplay]; 38 | }); 39 | } 40 | }); 41 | } 42 | 43 | #pragma mark - private instance method 44 | 45 | - (CGFloat)distanceA:(CGPoint)pointA toB:(CGPoint)pointB { 46 | return sqrt(pow(fabs(pointA.x - pointB.x), 2) + pow(fabs(pointA.y - pointB.y), 2)); 47 | } 48 | 49 | - (UIImage *)preDrawPathImage { 50 | UIImage *pathImage; 51 | UIGraphicsBeginImageContextWithOptions(self.bounds.size, 0, [UIScreen mainScreen].scale); 52 | CGContextRef context = UIGraphicsGetCurrentContext(); 53 | 54 | //設定線條的粗細, 以及圓角 55 | CGContextSetLineCap(context, kCGLineCapRound); 56 | CGContextSetLineJoin(context, kCGLineJoinRound); 57 | CGContextSetLineWidth(context, self.hudLineWidth); 58 | 59 | //劃勾勾的線 60 | CGFloat length = self.length; 61 | for (NSInteger index = 0; index < self.drawPath.count; index++) { 62 | NSArray *subArray = self.drawPath[index]; 63 | CGPoint firstPoint = [[subArray firstObject] CGPointValue]; 64 | CGContextMoveToPoint(context, firstPoint.x, firstPoint.y); 65 | 66 | BOOL isBreak = NO; 67 | for (NSInteger subIndex = 0; subIndex < subArray.count - 1; subIndex++) { 68 | CGPoint pointA = [subArray[subIndex] CGPointValue]; 69 | CGPoint pointB = [subArray[subIndex + 1] CGPointValue]; 70 | CGFloat distance = [self distanceA:pointA toB:pointB]; 71 | if (length < distance) { 72 | CGFloat percentA = length / distance; 73 | CGFloat percentB = 1 - percentA; 74 | CGPoint newPoint = CGPointMake(pointA.x * percentB + pointB.x * percentA, pointA.y * percentB + pointB.y * percentA); 75 | CGContextAddLineToPoint(context, newPoint.x, newPoint.y); 76 | isBreak = YES; 77 | break; 78 | } 79 | else { 80 | CGContextAddLineToPoint(context, pointB.x, pointB.y); 81 | length -= distance; 82 | } 83 | } 84 | 85 | if (isBreak) { 86 | break; 87 | } 88 | } 89 | CGContextSetRGBStrokeColor(context, self.pathColor.r, self.pathColor.g, self.pathColor.b, self.pathColor.a); 90 | 91 | //著色 92 | CGContextStrokePath(context); 93 | pathImage = UIGraphicsGetImageFromCurrentImageContext(); 94 | UIGraphicsEndImageContext(); 95 | return pathImage; 96 | } 97 | 98 | #pragma mark - method override 99 | 100 | //這邊主要就只負責把圖畫出來 101 | - (void)drawRect:(CGRect)rect { 102 | [super drawRect:rect]; 103 | [self.pathImage drawInRect:rect]; 104 | } 105 | 106 | #pragma mark - life cycle 107 | 108 | - (id)initWithFrame:(CGRect)frame { 109 | self = [super initWithFrame:frame]; 110 | if (self) { 111 | //初始值 112 | self.backgroundColor = [UIColor clearColor]; 113 | self.length = 0; 114 | self.displayLink = [[DaiInboxDisplayLink alloc] initWithDelegate:self]; 115 | } 116 | return self; 117 | } 118 | 119 | - (void)willMoveToSuperview:(UIView *)newSuperview { 120 | //從 newSuperview 的有無可以判斷現在是被加入或是被移除 121 | if (!newSuperview) { 122 | [self.displayLink removeDisplayLink]; 123 | } 124 | } 125 | 126 | @end 127 | -------------------------------------------------------------------------------- /DaiInboxHUD.xcodeproj/xcuserdata/ChilunChen.xcuserdatad/xcschemes/DaiInboxHUD.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 94 | 100 | 101 | 102 | 103 | 105 | 106 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /DaiInboxHUD/DaiInboxHUD/DaiInboxHUD.m: -------------------------------------------------------------------------------- 1 | // 2 | // DaiInboxHUD.m 3 | // DaiInboxHUD 4 | // 5 | // Created by 啟倫 陳 on 2014/10/31. 6 | // Copyright (c) 2014年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import "DaiInboxHUD.h" 10 | #import 11 | #import "DaiIndoxWindow.h" 12 | #import "DaiInboxViewController.h" 13 | 14 | @implementation DaiInboxHUD 15 | 16 | #pragma mark - DaiIndoxWindowDelegate 17 | 18 | + (BOOL)shouldHandleTouchAtPoint:(CGPoint)point { 19 | 20 | // 如果 allowUserInteraction = YES, 表示這個 window 不需要 handle touch event, 因此, 回傳是反相的 21 | DaiInboxViewController *inboxViewController = (DaiInboxViewController *)[self hudWindow].rootViewController; 22 | return !inboxViewController.allowUserInteraction; 23 | } 24 | 25 | #pragma mark - private class method 26 | 27 | + (DaiIndoxWindow *)hudWindow { 28 | if (!objc_getAssociatedObject(self, _cmd)) { 29 | DaiIndoxWindow *newWindow = [[DaiIndoxWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 30 | newWindow.eventDelegate = (id )self; 31 | [self setHudWindow:newWindow]; 32 | } 33 | return objc_getAssociatedObject(self, _cmd); 34 | } 35 | 36 | + (void)setHudWindow:(DaiIndoxWindow *)hudWindow { 37 | objc_setAssociatedObject(self, @selector(hudWindow), hudWindow, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 38 | } 39 | 40 | + (DaiInboxViewController *)inboxViewControllerByCopied:(CopiedHUD)copied byType:(DaiInboxHUDType)type andMessage:(NSAttributedString *)message { 41 | DaiInboxHUD *inboxHUD = nil; 42 | if (copied) { 43 | inboxHUD = copied([[self shared] copy]); 44 | } 45 | else { 46 | inboxHUD = [self shared]; 47 | } 48 | DaiInboxViewController *inboxViewController = [DaiInboxViewController new]; 49 | inboxViewController.colors = inboxHUD.colors; 50 | inboxViewController.backgroundColor = inboxHUD.backgroundColor; 51 | inboxViewController.maskColor = inboxHUD.maskColor; 52 | inboxViewController.lineWidth = inboxHUD.lineWidth; 53 | inboxViewController.checkmarkColor = inboxHUD.checkmarkColor; 54 | inboxViewController.crossColor = inboxHUD.crossColor; 55 | inboxViewController.allowUserInteraction = inboxHUD.allowUserInteraction; 56 | inboxViewController.message = message; 57 | inboxViewController.type = type; 58 | return inboxViewController; 59 | } 60 | 61 | #pragma mark - class method 62 | 63 | #pragma mark * 轉圈效果 64 | 65 | + (void)show { 66 | [self showMessage:nil]; 67 | } 68 | 69 | + (void)showThenHideAfterDelay:(NSTimeInterval)delay { 70 | [self showMessage:nil hideAfterDelay:delay]; 71 | } 72 | 73 | + (void)showMessage:(NSAttributedString *)message { 74 | [self showMessage:message hideAfterDelay:-1]; 75 | } 76 | 77 | + (void)showMessage:(NSAttributedString *)message hideAfterDelay:(NSTimeInterval)delay { 78 | [self showCopied:nil andMessage:message hideAfterDelay:delay]; 79 | } 80 | 81 | + (void)showCopied:(CopiedHUD)copied { 82 | [self showCopied:copied andMessage:nil]; 83 | } 84 | 85 | + (void)showCopied:(CopiedHUD)copied thenHideAfterDelay:(NSTimeInterval)delay { 86 | [self showCopied:copied andMessage:nil hideAfterDelay:delay]; 87 | } 88 | 89 | + (void)showCopied:(CopiedHUD)copied andMessage:(NSAttributedString *)message { 90 | [self showCopied:copied andMessage:message hideAfterDelay:-1]; 91 | } 92 | 93 | + (void)showCopied:(CopiedHUD)copied andMessage:(NSAttributedString *)message hideAfterDelay:(NSTimeInterval)delay { 94 | [self hudWindow].rootViewController = [self inboxViewControllerByCopied:copied byType:DaiInboxHUDTypeDefault andMessage:message]; 95 | [[self hudWindow] makeKeyAndVisible]; 96 | [self hideAfterDelay:delay]; 97 | } 98 | 99 | #pragma mark * 打勾效果 100 | 101 | + (void)showSuccess { 102 | [self showSuccessMessage:nil]; 103 | } 104 | 105 | + (void)showSuccessThenHideAfterDelay:(NSTimeInterval)delay { 106 | [self showSuccessMessage:nil hideAfterDelay:delay]; 107 | } 108 | 109 | + (void)showSuccessMessage:(NSAttributedString *)message { 110 | [self showSuccessMessage:message hideAfterDelay:-1]; 111 | } 112 | 113 | + (void)showSuccessMessage:(NSAttributedString *)message hideAfterDelay:(NSTimeInterval)delay { 114 | [self showSuccessCopied:nil andMessage:message hideAfterDelay:delay]; 115 | } 116 | 117 | + (void)showSuccessCopied:(CopiedHUD)copied { 118 | [self showSuccessCopied:copied andMessage:nil]; 119 | } 120 | 121 | + (void)showSuccessCopied:(CopiedHUD)copied thenHideAfterDelay:(NSTimeInterval)delay { 122 | [self showSuccessCopied:copied andMessage:nil hideAfterDelay:delay]; 123 | } 124 | 125 | + (void)showSuccessCopied:(CopiedHUD)copied andMessage:(NSAttributedString *)message { 126 | [self showSuccessCopied:copied andMessage:message hideAfterDelay:-1]; 127 | } 128 | 129 | + (void)showSuccessCopied:(CopiedHUD)copied andMessage:(NSAttributedString *)message hideAfterDelay:(NSTimeInterval)delay { 130 | [self hudWindow].rootViewController = [self inboxViewControllerByCopied:copied byType:DaiInboxHUDTypeSuccess andMessage:message]; 131 | [[self hudWindow] makeKeyAndVisible]; 132 | [self hideAfterDelay:delay]; 133 | } 134 | 135 | #pragma mark * 打叉效果 136 | 137 | + (void)showFail { 138 | [self showFailMessage:nil]; 139 | } 140 | 141 | + (void)showFailThenHideAfterDelay:(NSTimeInterval)delay { 142 | [self showFailMessage:nil hideAfterDelay:delay]; 143 | } 144 | 145 | + (void)showFailMessage:(NSAttributedString *)message { 146 | [self showFailMessage:message hideAfterDelay:-1]; 147 | } 148 | 149 | + (void)showFailMessage:(NSAttributedString *)message hideAfterDelay:(NSTimeInterval)delay { 150 | [self showFailCopied:nil andMessage:message hideAfterDelay:delay]; 151 | } 152 | 153 | + (void)showFailCopied:(CopiedHUD)copied { 154 | [self showFailCopied:copied andMessage:nil]; 155 | } 156 | 157 | + (void)showFailCopied:(CopiedHUD)copied thenHideAfterDelay:(NSTimeInterval)delay { 158 | [self showFailCopied:copied andMessage:nil hideAfterDelay:delay]; 159 | } 160 | 161 | + (void)showFailCopied:(CopiedHUD)copied andMessage:(NSAttributedString *)message { 162 | [self showFailCopied:copied andMessage:message hideAfterDelay:-1]; 163 | } 164 | 165 | + (void)showFailCopied:(CopiedHUD)copied andMessage:(NSAttributedString *)message hideAfterDelay:(NSTimeInterval)delay { 166 | [self hudWindow].rootViewController = [self inboxViewControllerByCopied:copied byType:DaiInboxHUDTypeFail andMessage:message]; 167 | [[self hudWindow] makeKeyAndVisible]; 168 | [self hideAfterDelay:delay]; 169 | } 170 | 171 | #pragma mark * 隱藏 hud 172 | 173 | + (void)hide { 174 | __weak id weakSelf = self; 175 | [[self hudWindow].rootViewController performSelector:@selector(hide:) withObject: ^{ 176 | if (weakSelf) { 177 | __strong id strongSelf = weakSelf; 178 | [strongSelf hudWindow].hidden = YES; 179 | [strongSelf setHudWindow:nil]; 180 | [[UIApplication sharedApplication].keyWindow makeKeyWindow]; 181 | } 182 | }]; 183 | } 184 | 185 | + (void)hideAfterDelay:(NSTimeInterval)delay { 186 | if (delay > 0) { 187 | id objectSelf = self; 188 | [objectSelf performSelector:@selector(hide) withObject:nil afterDelay:delay]; 189 | } 190 | } 191 | 192 | #pragma mark * 共用實例 193 | 194 | + (DaiInboxHUD *)shared { 195 | static dispatch_once_t onceToken; 196 | dispatch_once(&onceToken, ^{ 197 | DaiInboxHUD *sharedHUD = [DaiInboxHUD new]; 198 | sharedHUD.colors = @[[UIColor redColor], [UIColor greenColor], [UIColor yellowColor], [UIColor blueColor]]; 199 | sharedHUD.checkmarkColor = [UIColor greenColor]; 200 | sharedHUD.crossColor = [UIColor redColor]; 201 | sharedHUD.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.65f]; 202 | sharedHUD.maskColor = [UIColor clearColor]; 203 | sharedHUD.lineWidth = 2.0f; 204 | sharedHUD.allowUserInteraction = NO; 205 | objc_setAssociatedObject(self, _cmd, sharedHUD, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 206 | }); 207 | return objc_getAssociatedObject(self, _cmd); 208 | } 209 | 210 | #pragma mark - NSCopying 211 | 212 | - (id)copyWithZone:(NSZone *)zone { 213 | DaiInboxHUD *newHUD = [[DaiInboxHUD allocWithZone:zone] init]; 214 | newHUD.colors = self.colors; 215 | newHUD.checkmarkColor = self.checkmarkColor; 216 | newHUD.crossColor = self.crossColor; 217 | newHUD.backgroundColor = self.backgroundColor; 218 | newHUD.maskColor = self.maskColor; 219 | newHUD.lineWidth = self.lineWidth; 220 | newHUD.allowUserInteraction = self.allowUserInteraction; 221 | return newHUD; 222 | } 223 | 224 | @end 225 | -------------------------------------------------------------------------------- /DaiInboxHUD/DaiInboxHUD/DaiInboxView.m: -------------------------------------------------------------------------------- 1 | // 2 | // DaiInboxView.m 3 | // DaiInboxHUD 4 | // 5 | // Created by 啟倫 陳 on 2014/10/31. 6 | // Copyright (c) 2014年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import "DaiInboxView.h" 10 | #import 11 | #import "UIColor+MixColor.h" 12 | 13 | #define degreesToRadian(angle) (M_PI * (angle) / 180.0) 14 | 15 | //控制最大最小長度, 以及每次迭代長度 16 | #define maxLength 200.0f 17 | #define minLength 2.0f 18 | #define lengthIteration 8.0f 19 | 20 | //每次旋轉角度 21 | #define rotateIteration 4.0f 22 | 23 | //動畫的 fps 設定, 以及最長最短時要停留的 frame 張數 24 | #define framePerSecond 60.0f 25 | #define maxWaitingSecond 0.5f 26 | 27 | typedef enum { 28 | CricleLengthStatusDecrease, 29 | CricleLengthStatusIncrease, 30 | CricleLengthStatusWaiting 31 | } CricleLengthStatus; 32 | 33 | @interface DaiInboxView () 34 | 35 | //當前長度, 旋轉角度, 狀態 36 | @property (nonatomic, assign) NSInteger length; 37 | @property (nonatomic, assign) NSInteger rotateAngle; 38 | @property (nonatomic, assign) CricleLengthStatus status; 39 | 40 | //變換的顏色, default 是 紅 -> 綠 -> 黃 -> 藍, 以及當前在哪一個顏色上 41 | @property (nonatomic, assign) NSInteger colorIndex; 42 | @property (nonatomic, strong) UIColor *finalColor; 43 | @property (nonatomic, strong) UIColor *prevColor; 44 | @property (nonatomic, strong) UIColor *gradualColor; 45 | 46 | //已等待時間 47 | @property (nonatomic, assign) NSTimeInterval waitingSecond; 48 | 49 | //固定的中心點及半徑, 不需每次計算 50 | @property (nonatomic, assign) CGPoint circleCenter; 51 | @property (nonatomic, assign) CGFloat circleRadius; 52 | 53 | //預先畫好的圈圈 54 | @property (nonatomic, strong) UIImage *circleImage; 55 | 56 | @property (nonatomic, strong) DaiInboxDisplayLink *displayLink; 57 | 58 | @end 59 | 60 | @implementation DaiInboxView 61 | 62 | #pragma mark - DaiInboxDisplayLinkDelegate 63 | 64 | //用更合理的概念來做動畫這一個部分 65 | //以 rotateIteration 來說的話, 我們假設在 fps 60 也就是約 0.01666666666 秒要移動 4.0f 個角度 66 | //但是在真實的世界裡, 也許有時候會比這個數值多, 有時候則會少 67 | //於是我們需要用另一種更合理的概念來實現, 這邊的 deltaTime 會傳回幀與幀之前的間隔時間, 68 | //我假設當這個數值 > 60fps 時, 則以全速來跑, 反之, 則依比例縮減他們的變動 69 | //效果可以讓動畫看起來比較不會有違和感 70 | - (void)displayWillUpdateWithDeltaTime:(CFTimeInterval)deltaTime { 71 | __weak DaiInboxView *weakSelf = self; 72 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 73 | if (weakSelf) { 74 | __strong DaiInboxView *strongSelf = weakSelf; 75 | 76 | CGFloat deltaValue = MIN(1.0f, deltaTime / (1.0f / framePerSecond)); 77 | 78 | switch (strongSelf.status) { 79 | case CricleLengthStatusDecrease: 80 | { 81 | strongSelf.length -= lengthIteration * deltaValue; 82 | strongSelf.rotateAngle += rotateIteration * deltaValue; 83 | 84 | //當長度扣到過短時, 讓他停下來, 設定好顏色, 準備另一個階段 85 | if (strongSelf.length <= minLength) { 86 | strongSelf.length = minLength; 87 | strongSelf.status = CricleLengthStatusWaiting; 88 | strongSelf.colorIndex++; 89 | strongSelf.colorIndex %= [strongSelf.hudColors count]; 90 | strongSelf.prevColor = strongSelf.finalColor; 91 | strongSelf.finalColor = strongSelf.hudColors[strongSelf.colorIndex]; 92 | } 93 | break; 94 | } 95 | 96 | case CricleLengthStatusIncrease: 97 | { 98 | strongSelf.length += lengthIteration * deltaValue; 99 | CGFloat deltaLength = sin(((float)lengthIteration / 360) * M_PI_2) * 360; 100 | strongSelf.rotateAngle += (rotateIteration + deltaLength) * deltaValue; 101 | 102 | //長度過長時, 讓他停下來, 準備去另一個階段 103 | if (strongSelf.length >= maxLength) { 104 | strongSelf.length = maxLength; 105 | strongSelf.status = CricleLengthStatusWaiting; 106 | } 107 | break; 108 | } 109 | 110 | case CricleLengthStatusWaiting: 111 | { 112 | strongSelf.waitingSecond += deltaTime; 113 | strongSelf.rotateAngle += rotateIteration * deltaValue; 114 | 115 | //這個狀態下需要多算一個漸變色 116 | if (strongSelf.length == minLength) { 117 | CGFloat colorAPercent = ((float)strongSelf.waitingSecond / maxWaitingSecond); 118 | CGFloat colorBPercent = 1 - colorAPercent; 119 | UIColor *transparentColorA = [strongSelf.finalColor colorWithAlphaComponent:colorAPercent]; 120 | UIColor *transparentColorB = [strongSelf.prevColor colorWithAlphaComponent:colorBPercent];; 121 | strongSelf.gradualColor = [transparentColorA mixColor:transparentColorB]; 122 | } 123 | 124 | //當幀數到達指定的數量, 按照他的狀態, 分配他該去的狀態 125 | if (strongSelf.waitingSecond >= maxWaitingSecond) { 126 | strongSelf.waitingSecond = 0; 127 | if (strongSelf.length == minLength) { 128 | strongSelf.status = CricleLengthStatusIncrease; 129 | } 130 | else { 131 | strongSelf.status = CricleLengthStatusDecrease; 132 | } 133 | } 134 | break; 135 | } 136 | } 137 | strongSelf.rotateAngle %= 360; 138 | strongSelf.circleImage = [strongSelf preDrawCircleImage]; 139 | 140 | //算完以後回 main thread 囉 141 | dispatch_async(dispatch_get_main_queue(), ^{ 142 | strongSelf.transform = CGAffineTransformMakeRotation(degreesToRadian(strongSelf.rotateAngle)); 143 | [strongSelf setNeedsDisplay]; 144 | }); 145 | } 146 | }); 147 | } 148 | 149 | #pragma mark - private 150 | 151 | - (UIImage *)preDrawCircleImage { 152 | UIImage *circleImage; 153 | UIGraphicsBeginImageContextWithOptions(self.bounds.size, 0, [UIScreen mainScreen].scale); 154 | CGContextRef context = UIGraphicsGetCurrentContext(); 155 | 156 | //設定線條的粗細, 以及圓角 157 | CGContextSetLineCap(context, kCGLineCapRound); 158 | CGContextSetLineJoin(context, kCGLineJoinRound); 159 | CGContextSetLineWidth(context, self.hudLineWidth); 160 | 161 | //設定線條的顏色, 只有在最短狀態的時候才需要用漸變色 162 | if (self.status == CricleLengthStatusWaiting && self.length == minLength) { 163 | CGContextSetRGBStrokeColor(context, self.gradualColor.r, self.gradualColor.g, self.gradualColor.b, self.gradualColor.a); 164 | } 165 | else { 166 | CGContextSetRGBStrokeColor(context, self.finalColor.r, self.finalColor.g, self.finalColor.b, self.finalColor.a); 167 | } 168 | 169 | //設定半弧的中心, 半徑, 起始以及終點 170 | CGFloat deltaLength = sin(((float)self.length / 360) * M_PI_2) * 360; 171 | CGFloat startAngle = degreesToRadian(-deltaLength); 172 | CGContextAddArc(context, self.circleCenter.x, self.circleCenter.y, self.circleRadius, startAngle, 0, 0); 173 | 174 | //著色 175 | CGContextStrokePath(context); 176 | circleImage = UIGraphicsGetImageFromCurrentImageContext(); 177 | UIGraphicsEndImageContext(); 178 | return circleImage; 179 | } 180 | 181 | #pragma mark - method override 182 | 183 | //這邊主要就只負責把圖畫出來 184 | - (void)drawRect:(CGRect)rect { 185 | [super drawRect:rect]; 186 | [self.circleImage drawInRect:rect]; 187 | } 188 | 189 | #pragma mark - life cycle 190 | 191 | - (id)initWithFrame:(CGRect)frame { 192 | self = [super initWithFrame:frame]; 193 | if (self) { 194 | //初始值 195 | self.backgroundColor = [UIColor clearColor]; 196 | self.rotateAngle = arc4random() % 360; 197 | self.length = maxLength; 198 | self.status = CricleLengthStatusDecrease; 199 | self.waitingSecond = 0; 200 | CGFloat width = CGRectGetWidth(frame); 201 | CGFloat height = CGRectGetHeight(frame); 202 | self.circleCenter = CGPointMake(width / 2, height / 2); 203 | self.circleRadius = width / 3; 204 | self.displayLink = [[DaiInboxDisplayLink alloc] initWithDelegate:self]; 205 | } 206 | return self; 207 | } 208 | 209 | - (void)willMoveToSuperview:(UIView *)newSuperview { 210 | //從 newSuperview 的有無可以判斷現在是被加入或是被移除 211 | if (newSuperview) { 212 | self.colorIndex = arc4random() % [self.hudColors count]; 213 | self.finalColor = self.hudColors[self.colorIndex]; 214 | self.circleImage = [self preDrawCircleImage]; 215 | } 216 | else { 217 | [self.displayLink removeDisplayLink]; 218 | } 219 | } 220 | 221 | @end 222 | -------------------------------------------------------------------------------- /DaiInboxHUD/DaiInboxHUD/DaiInboxViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // DaiInboxViewController.m 3 | // DaiInboxHUD 4 | // 5 | // Created by 啟倫 陳 on 2014/11/4. 6 | // Copyright (c) 2014年 ChilunChen. All rights reserved. 7 | // 8 | 9 | #import "DaiInboxViewController.h" 10 | #import "DaiInboxView.h" 11 | #import "DaiDrawPathView.h" 12 | 13 | #define inboxViewSize 30.0f 14 | #define borderGap 10.0f 15 | 16 | @implementation UIView (Center) 17 | 18 | - (CGRect)centerInOrientation:(UIInterfaceOrientation)orientation { 19 | CGRect screenBounds = [UIScreen mainScreen].bounds; 20 | CGFloat halfScreenWidth = CGRectGetWidth(screenBounds) / 2; 21 | CGFloat halfScreenHeight = CGRectGetHeight(screenBounds) / 2; 22 | CGRect newFrame = self.frame; 23 | CGFloat halfFrameWidth = CGRectGetWidth(newFrame) / 2; 24 | CGFloat halfFrameHeight = CGRectGetHeight(newFrame) / 2; 25 | if (UIDeviceOrientationIsPortrait(orientation)) { 26 | newFrame.origin.x = halfScreenWidth - halfFrameWidth; 27 | newFrame.origin.y = halfScreenHeight - halfFrameHeight; 28 | } 29 | else { 30 | newFrame.origin.x = halfScreenWidth - halfFrameHeight; 31 | newFrame.origin.y = halfScreenHeight - halfFrameWidth; 32 | 33 | //在 ios7 的時候, 不論手機轉橫轉直, screenSize always 是 320, 568 34 | //而 ios8 的時候, 手機則會根據轉橫或是轉直而改變, ex: 直立時是 320, 568, 橫向為 568, 320 35 | if ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f) { 36 | CGFloat swapValue = newFrame.origin.x; 37 | newFrame.origin.x = newFrame.origin.y; 38 | newFrame.origin.y = swapValue; 39 | } 40 | } 41 | return newFrame; 42 | } 43 | 44 | @end 45 | 46 | @interface DaiInboxViewController () 47 | 48 | @property (nonatomic, strong) UIView *centerView; 49 | 50 | @end 51 | 52 | @implementation DaiInboxViewController 53 | 54 | #pragma mark - instance method 55 | 56 | // hide hud 然後帶個動畫 57 | - (void)hide:(void (^)(void))completion { 58 | __weak DaiInboxViewController *wealSelf = self; 59 | [UIView animateWithDuration:0.3 / 1.5 animations: ^{ 60 | wealSelf.centerView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9); 61 | } completion: ^(BOOL finished) { 62 | [UIView animateWithDuration:0.3 / 2 animations: ^{ 63 | wealSelf.centerView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1); 64 | } completion: ^(BOOL finished) { 65 | [UIView animateWithDuration:0.3 / 2 animations: ^{ 66 | wealSelf.centerView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001); 67 | } completion: ^(BOOL finished) { 68 | completion(); 69 | }]; 70 | }]; 71 | }]; 72 | } 73 | 74 | #pragma mark - private instance method 75 | 76 | - (void)setupHUD { 77 | CGRect messageFrame = CGRectZero; 78 | UILabel *hudMessageLabel; 79 | CGFloat messageLabelWidth = 0; 80 | CGFloat messageLabelHeight = 0; 81 | 82 | //如果 hud message 有東西, 先算他的 size 83 | if (self.message) { 84 | hudMessageLabel = [UILabel new]; 85 | hudMessageLabel.attributedText = self.message; 86 | [hudMessageLabel sizeToFit]; 87 | messageFrame = hudMessageLabel.frame; 88 | messageLabelWidth = CGRectGetWidth(hudMessageLabel.frame); 89 | messageLabelHeight = CGRectGetHeight(hudMessageLabel.frame); 90 | } 91 | 92 | //設定好 centerview 的大小 93 | //寬度的算法, 取 hud 本身或是 label 的最大者, 加上左右兩旁的邊框 94 | CGFloat centerViewWidth = MAX(inboxViewSize, CGRectGetWidth(messageFrame)) + borderGap * 2; 95 | 96 | //高度的算法, 只有 hud 的時候就是 hud 本身加上上下的邊框, 多 label 的話, 要在 hud 跟 label 之間多塞一個一半大小的 gap 97 | CGFloat centerViewHeight = inboxViewSize + messageLabelHeight + borderGap * 2 + ((self.message) ? borderGap * 0.5 : 0); 98 | self.centerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, centerViewWidth, centerViewHeight)]; 99 | self.centerView.frame = [self.centerView centerInOrientation:self.interfaceOrientation]; 100 | self.centerView.backgroundColor = self.backgroundColor; 101 | self.centerView.layer.cornerRadius = 5.0f; 102 | self.centerView.layer.masksToBounds = YES; 103 | 104 | //開始把東西加入 centerView 105 | CGFloat objectHeight = borderGap; 106 | 107 | //加入 hud 主體 108 | CGFloat halfCenterWidth = CGRectGetWidth(self.centerView.frame) / 2; 109 | UIView *hudView = nil; 110 | switch (self.type) { 111 | case DaiInboxHUDTypeDefault: 112 | { 113 | DaiInboxView *inboxView = [[DaiInboxView alloc] initWithFrame:CGRectMake(halfCenterWidth - inboxViewSize / 2, objectHeight, inboxViewSize, inboxViewSize)]; 114 | inboxView.hudColors = self.colors; 115 | inboxView.hudLineWidth = self.lineWidth; 116 | hudView = inboxView; 117 | break; 118 | } 119 | 120 | case DaiInboxHUDTypeSuccess: 121 | { 122 | DaiDrawPathView *successView = [[DaiDrawPathView alloc] initWithFrame:CGRectMake(halfCenterWidth - inboxViewSize / 2, objectHeight, inboxViewSize, inboxViewSize)]; 123 | successView.pathColor = self.checkmarkColor; 124 | successView.hudLineWidth = self.lineWidth; 125 | successView.drawPath = @[@[[NSValue valueWithCGPoint:CGPointMake(inboxViewSize * 0.25f, inboxViewSize * 0.5f)], [NSValue valueWithCGPoint:CGPointMake(inboxViewSize * 0.5f, inboxViewSize * 0.75f)], [NSValue valueWithCGPoint:CGPointMake(inboxViewSize * 0.85f, inboxViewSize * 0.25f)]]]; 126 | successView.lengthIteration = 0.8f; 127 | hudView = successView; 128 | break; 129 | } 130 | 131 | case DaiInboxHUDTypeFail: 132 | { 133 | DaiDrawPathView *failView = [[DaiDrawPathView alloc] initWithFrame:CGRectMake(halfCenterWidth - inboxViewSize / 2, objectHeight, inboxViewSize, inboxViewSize)]; 134 | failView.pathColor = self.crossColor; 135 | failView.hudLineWidth = self.lineWidth; 136 | failView.drawPath = @[@[[NSValue valueWithCGPoint:CGPointMake(inboxViewSize * 0.15f, inboxViewSize * 0.15f)], [NSValue valueWithCGPoint:CGPointMake(inboxViewSize * 0.85f, inboxViewSize * 0.85f)]], @[[NSValue valueWithCGPoint:CGPointMake(inboxViewSize * 0.85f, inboxViewSize * 0.15f)], [NSValue valueWithCGPoint:CGPointMake(inboxViewSize * 0.15f, inboxViewSize * 0.85f)]]]; 137 | failView.lengthIteration = 1.6f; 138 | hudView = failView; 139 | break; 140 | } 141 | } 142 | [self.centerView addSubview:hudView]; 143 | CGFloat hudViewHeight = CGRectGetHeight(hudView.frame); 144 | objectHeight += hudViewHeight + ((self.message) ? borderGap * 0.5 : 0); 145 | 146 | //如果有 label 的話就加 147 | if (self.message) { 148 | hudMessageLabel.frame = CGRectMake(halfCenterWidth - messageLabelWidth / 2, objectHeight, messageLabelWidth, messageLabelHeight); 149 | [self.centerView addSubview:hudMessageLabel]; 150 | } 151 | 152 | //放到 view 裡 153 | [self.view addSubview:self.centerView]; 154 | } 155 | 156 | #pragma mark - rotate 157 | 158 | //for ios8 159 | - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id )coordinator { 160 | CGRect newFrame = self.centerView.frame; 161 | CGFloat halfFrameWidth = CGRectGetWidth(newFrame) / 2; 162 | CGFloat halfFrameHeight = CGRectGetHeight(newFrame) / 2; 163 | newFrame.origin.x = size.width / 2 - halfFrameWidth; 164 | newFrame.origin.y = size.height / 2 - halfFrameHeight; 165 | __weak DaiInboxViewController *weakSelf = self; 166 | [UIView animateWithDuration:[coordinator transitionDuration] animations: ^{ 167 | weakSelf.centerView.frame = newFrame; 168 | }]; 169 | } 170 | 171 | //for ios7 172 | - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 173 | CGRect newFrame = [self.centerView centerInOrientation:toInterfaceOrientation]; 174 | __weak DaiInboxViewController *weakSelf = self; 175 | [UIView animateWithDuration:duration animations: ^{ 176 | weakSelf.centerView.frame = newFrame; 177 | }]; 178 | } 179 | 180 | #pragma mark - life cycle 181 | 182 | - (void)viewDidLoad { 183 | [super viewDidLoad]; 184 | self.view.backgroundColor = self.maskColor; 185 | [self setupHUD]; 186 | 187 | //一開始的彈出動畫效果 188 | self.centerView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001); 189 | __weak DaiInboxViewController *wealSelf = self; 190 | [UIView animateWithDuration:0.3 / 1.5 animations: ^{ 191 | wealSelf.centerView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1); 192 | } completion: ^(BOOL finished) { 193 | [UIView animateWithDuration:0.3 / 2 animations: ^{ 194 | wealSelf.centerView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9); 195 | } completion: ^(BOOL finished) { 196 | [UIView animateWithDuration:0.3 / 2 animations: ^{ 197 | wealSelf.centerView.transform = CGAffineTransformIdentity; 198 | }]; 199 | }]; 200 | }]; 201 | } 202 | 203 | @end 204 | -------------------------------------------------------------------------------- /DaiInboxHUD.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0131ED391A037767001C0DD8 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 0131ED381A037767001C0DD8 /* main.m */; }; 11 | 0131ED3C1A037767001C0DD8 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 0131ED3B1A037767001C0DD8 /* AppDelegate.m */; }; 12 | 0131ED441A037767001C0DD8 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0131ED431A037767001C0DD8 /* Images.xcassets */; }; 13 | 0131ED531A037767001C0DD8 /* DaiInboxHUDTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0131ED521A037767001C0DD8 /* DaiInboxHUDTests.m */; }; 14 | 0131ED5F1A037799001C0DD8 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0131ED5D1A037799001C0DD8 /* MainViewController.m */; }; 15 | 0131ED601A037799001C0DD8 /* MainViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0131ED5E1A037799001C0DD8 /* MainViewController.xib */; }; 16 | 0131ED621A0377A4001C0DD8 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 0131ED611A0377A4001C0DD8 /* Default-568h@2x.png */; }; 17 | 0131ED661A037896001C0DD8 /* DaiInboxHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = 0131ED651A037896001C0DD8 /* DaiInboxHUD.m */; }; 18 | 0131ED691A03794B001C0DD8 /* DaiInboxView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0131ED681A03794B001C0DD8 /* DaiInboxView.m */; }; 19 | 0187ACC31A087FF800094D67 /* DaiIndoxWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 0187ACC21A087FF800094D67 /* DaiIndoxWindow.m */; }; 20 | 0187ACC61A08817F00094D67 /* DaiInboxViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0187ACC51A08817F00094D67 /* DaiInboxViewController.m */; }; 21 | 01D0C7781A0CB61C006AA033 /* DaiInboxDisplayLink.m in Sources */ = {isa = PBXBuildFile; fileRef = 01D0C7771A0CB61C006AA033 /* DaiInboxDisplayLink.m */; }; 22 | 1C19DD321B79EB9300EFDBCB /* UIColor+MixColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C19DD311B79EB9300EFDBCB /* UIColor+MixColor.m */; }; 23 | 1C65ABD81B7C33F40020D922 /* DaiDrawPathView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C65ABD71B7C33F40020D922 /* DaiDrawPathView.m */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXContainerItemProxy section */ 27 | 0131ED4D1A037767001C0DD8 /* PBXContainerItemProxy */ = { 28 | isa = PBXContainerItemProxy; 29 | containerPortal = 0131ED2B1A037767001C0DD8 /* Project object */; 30 | proxyType = 1; 31 | remoteGlobalIDString = 0131ED321A037767001C0DD8; 32 | remoteInfo = DaiInboxHUD; 33 | }; 34 | /* End PBXContainerItemProxy section */ 35 | 36 | /* Begin PBXFileReference section */ 37 | 0131ED331A037767001C0DD8 /* DaiInboxHUD.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DaiInboxHUD.app; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | 0131ED371A037767001C0DD8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 39 | 0131ED381A037767001C0DD8 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 40 | 0131ED3A1A037767001C0DD8 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 41 | 0131ED3B1A037767001C0DD8 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 42 | 0131ED431A037767001C0DD8 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 43 | 0131ED4C1A037767001C0DD8 /* DaiInboxHUDTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DaiInboxHUDTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | 0131ED511A037767001C0DD8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | 0131ED521A037767001C0DD8 /* DaiInboxHUDTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DaiInboxHUDTests.m; sourceTree = ""; }; 46 | 0131ED5C1A037799001C0DD8 /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = ""; }; 47 | 0131ED5D1A037799001C0DD8 /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = ""; }; 48 | 0131ED5E1A037799001C0DD8 /* MainViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainViewController.xib; sourceTree = ""; }; 49 | 0131ED611A0377A4001C0DD8 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 50 | 0131ED641A037896001C0DD8 /* DaiInboxHUD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaiInboxHUD.h; sourceTree = ""; }; 51 | 0131ED651A037896001C0DD8 /* DaiInboxHUD.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DaiInboxHUD.m; sourceTree = ""; }; 52 | 0131ED671A03794B001C0DD8 /* DaiInboxView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaiInboxView.h; sourceTree = ""; }; 53 | 0131ED681A03794B001C0DD8 /* DaiInboxView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DaiInboxView.m; sourceTree = ""; }; 54 | 0187ACC11A087FF800094D67 /* DaiIndoxWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaiIndoxWindow.h; sourceTree = ""; }; 55 | 0187ACC21A087FF800094D67 /* DaiIndoxWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DaiIndoxWindow.m; sourceTree = ""; }; 56 | 0187ACC41A08817F00094D67 /* DaiInboxViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaiInboxViewController.h; sourceTree = ""; }; 57 | 0187ACC51A08817F00094D67 /* DaiInboxViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DaiInboxViewController.m; sourceTree = ""; }; 58 | 01D0C7761A0CB61C006AA033 /* DaiInboxDisplayLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaiInboxDisplayLink.h; sourceTree = ""; }; 59 | 01D0C7771A0CB61C006AA033 /* DaiInboxDisplayLink.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DaiInboxDisplayLink.m; sourceTree = ""; }; 60 | 1C19DD301B79EB9300EFDBCB /* UIColor+MixColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+MixColor.h"; sourceTree = ""; }; 61 | 1C19DD311B79EB9300EFDBCB /* UIColor+MixColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+MixColor.m"; sourceTree = ""; }; 62 | 1C65ABD61B7C33F40020D922 /* DaiDrawPathView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaiDrawPathView.h; sourceTree = ""; }; 63 | 1C65ABD71B7C33F40020D922 /* DaiDrawPathView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DaiDrawPathView.m; sourceTree = ""; }; 64 | /* End PBXFileReference section */ 65 | 66 | /* Begin PBXFrameworksBuildPhase section */ 67 | 0131ED301A037767001C0DD8 /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | 0131ED491A037767001C0DD8 /* Frameworks */ = { 75 | isa = PBXFrameworksBuildPhase; 76 | buildActionMask = 2147483647; 77 | files = ( 78 | ); 79 | runOnlyForDeploymentPostprocessing = 0; 80 | }; 81 | /* End PBXFrameworksBuildPhase section */ 82 | 83 | /* Begin PBXGroup section */ 84 | 0131ED2A1A037767001C0DD8 = { 85 | isa = PBXGroup; 86 | children = ( 87 | 0131ED351A037767001C0DD8 /* DaiInboxHUD */, 88 | 0131ED4F1A037767001C0DD8 /* DaiInboxHUDTests */, 89 | 0131ED341A037767001C0DD8 /* Products */, 90 | ); 91 | sourceTree = ""; 92 | }; 93 | 0131ED341A037767001C0DD8 /* Products */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 0131ED331A037767001C0DD8 /* DaiInboxHUD.app */, 97 | 0131ED4C1A037767001C0DD8 /* DaiInboxHUDTests.xctest */, 98 | ); 99 | name = Products; 100 | sourceTree = ""; 101 | }; 102 | 0131ED351A037767001C0DD8 /* DaiInboxHUD */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | 0131ED631A037885001C0DD8 /* DaiInboxHUD */, 106 | 0131ED3A1A037767001C0DD8 /* AppDelegate.h */, 107 | 0131ED3B1A037767001C0DD8 /* AppDelegate.m */, 108 | 0131ED5C1A037799001C0DD8 /* MainViewController.h */, 109 | 0131ED5D1A037799001C0DD8 /* MainViewController.m */, 110 | 0131ED5E1A037799001C0DD8 /* MainViewController.xib */, 111 | 0131ED431A037767001C0DD8 /* Images.xcassets */, 112 | 0131ED361A037767001C0DD8 /* Supporting Files */, 113 | ); 114 | path = DaiInboxHUD; 115 | sourceTree = ""; 116 | }; 117 | 0131ED361A037767001C0DD8 /* Supporting Files */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | 0131ED611A0377A4001C0DD8 /* Default-568h@2x.png */, 121 | 0131ED371A037767001C0DD8 /* Info.plist */, 122 | 0131ED381A037767001C0DD8 /* main.m */, 123 | ); 124 | name = "Supporting Files"; 125 | sourceTree = ""; 126 | }; 127 | 0131ED4F1A037767001C0DD8 /* DaiInboxHUDTests */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | 0131ED521A037767001C0DD8 /* DaiInboxHUDTests.m */, 131 | 0131ED501A037767001C0DD8 /* Supporting Files */, 132 | ); 133 | path = DaiInboxHUDTests; 134 | sourceTree = ""; 135 | }; 136 | 0131ED501A037767001C0DD8 /* Supporting Files */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | 0131ED511A037767001C0DD8 /* Info.plist */, 140 | ); 141 | name = "Supporting Files"; 142 | sourceTree = ""; 143 | }; 144 | 0131ED631A037885001C0DD8 /* DaiInboxHUD */ = { 145 | isa = PBXGroup; 146 | children = ( 147 | 0131ED641A037896001C0DD8 /* DaiInboxHUD.h */, 148 | 0131ED651A037896001C0DD8 /* DaiInboxHUD.m */, 149 | 0187ACC11A087FF800094D67 /* DaiIndoxWindow.h */, 150 | 0187ACC21A087FF800094D67 /* DaiIndoxWindow.m */, 151 | 0187ACC41A08817F00094D67 /* DaiInboxViewController.h */, 152 | 0187ACC51A08817F00094D67 /* DaiInboxViewController.m */, 153 | 1C19DD301B79EB9300EFDBCB /* UIColor+MixColor.h */, 154 | 1C19DD311B79EB9300EFDBCB /* UIColor+MixColor.m */, 155 | 0131ED671A03794B001C0DD8 /* DaiInboxView.h */, 156 | 0131ED681A03794B001C0DD8 /* DaiInboxView.m */, 157 | 1C65ABD61B7C33F40020D922 /* DaiDrawPathView.h */, 158 | 1C65ABD71B7C33F40020D922 /* DaiDrawPathView.m */, 159 | 01D0C7761A0CB61C006AA033 /* DaiInboxDisplayLink.h */, 160 | 01D0C7771A0CB61C006AA033 /* DaiInboxDisplayLink.m */, 161 | ); 162 | path = DaiInboxHUD; 163 | sourceTree = ""; 164 | }; 165 | /* End PBXGroup section */ 166 | 167 | /* Begin PBXNativeTarget section */ 168 | 0131ED321A037767001C0DD8 /* DaiInboxHUD */ = { 169 | isa = PBXNativeTarget; 170 | buildConfigurationList = 0131ED561A037767001C0DD8 /* Build configuration list for PBXNativeTarget "DaiInboxHUD" */; 171 | buildPhases = ( 172 | 0131ED2F1A037767001C0DD8 /* Sources */, 173 | 0131ED301A037767001C0DD8 /* Frameworks */, 174 | 0131ED311A037767001C0DD8 /* Resources */, 175 | ); 176 | buildRules = ( 177 | ); 178 | dependencies = ( 179 | ); 180 | name = DaiInboxHUD; 181 | productName = DaiInboxHUD; 182 | productReference = 0131ED331A037767001C0DD8 /* DaiInboxHUD.app */; 183 | productType = "com.apple.product-type.application"; 184 | }; 185 | 0131ED4B1A037767001C0DD8 /* DaiInboxHUDTests */ = { 186 | isa = PBXNativeTarget; 187 | buildConfigurationList = 0131ED591A037767001C0DD8 /* Build configuration list for PBXNativeTarget "DaiInboxHUDTests" */; 188 | buildPhases = ( 189 | 0131ED481A037767001C0DD8 /* Sources */, 190 | 0131ED491A037767001C0DD8 /* Frameworks */, 191 | 0131ED4A1A037767001C0DD8 /* Resources */, 192 | ); 193 | buildRules = ( 194 | ); 195 | dependencies = ( 196 | 0131ED4E1A037767001C0DD8 /* PBXTargetDependency */, 197 | ); 198 | name = DaiInboxHUDTests; 199 | productName = DaiInboxHUDTests; 200 | productReference = 0131ED4C1A037767001C0DD8 /* DaiInboxHUDTests.xctest */; 201 | productType = "com.apple.product-type.bundle.unit-test"; 202 | }; 203 | /* End PBXNativeTarget section */ 204 | 205 | /* Begin PBXProject section */ 206 | 0131ED2B1A037767001C0DD8 /* Project object */ = { 207 | isa = PBXProject; 208 | attributes = { 209 | LastUpgradeCheck = 0610; 210 | ORGANIZATIONNAME = ChilunChen; 211 | TargetAttributes = { 212 | 0131ED321A037767001C0DD8 = { 213 | CreatedOnToolsVersion = 6.1; 214 | }; 215 | 0131ED4B1A037767001C0DD8 = { 216 | CreatedOnToolsVersion = 6.1; 217 | TestTargetID = 0131ED321A037767001C0DD8; 218 | }; 219 | }; 220 | }; 221 | buildConfigurationList = 0131ED2E1A037767001C0DD8 /* Build configuration list for PBXProject "DaiInboxHUD" */; 222 | compatibilityVersion = "Xcode 3.2"; 223 | developmentRegion = English; 224 | hasScannedForEncodings = 0; 225 | knownRegions = ( 226 | en, 227 | Base, 228 | ); 229 | mainGroup = 0131ED2A1A037767001C0DD8; 230 | productRefGroup = 0131ED341A037767001C0DD8 /* Products */; 231 | projectDirPath = ""; 232 | projectRoot = ""; 233 | targets = ( 234 | 0131ED321A037767001C0DD8 /* DaiInboxHUD */, 235 | 0131ED4B1A037767001C0DD8 /* DaiInboxHUDTests */, 236 | ); 237 | }; 238 | /* End PBXProject section */ 239 | 240 | /* Begin PBXResourcesBuildPhase section */ 241 | 0131ED311A037767001C0DD8 /* Resources */ = { 242 | isa = PBXResourcesBuildPhase; 243 | buildActionMask = 2147483647; 244 | files = ( 245 | 0131ED441A037767001C0DD8 /* Images.xcassets in Resources */, 246 | 0131ED601A037799001C0DD8 /* MainViewController.xib in Resources */, 247 | 0131ED621A0377A4001C0DD8 /* Default-568h@2x.png in Resources */, 248 | ); 249 | runOnlyForDeploymentPostprocessing = 0; 250 | }; 251 | 0131ED4A1A037767001C0DD8 /* Resources */ = { 252 | isa = PBXResourcesBuildPhase; 253 | buildActionMask = 2147483647; 254 | files = ( 255 | ); 256 | runOnlyForDeploymentPostprocessing = 0; 257 | }; 258 | /* End PBXResourcesBuildPhase section */ 259 | 260 | /* Begin PBXSourcesBuildPhase section */ 261 | 0131ED2F1A037767001C0DD8 /* Sources */ = { 262 | isa = PBXSourcesBuildPhase; 263 | buildActionMask = 2147483647; 264 | files = ( 265 | 1C65ABD81B7C33F40020D922 /* DaiDrawPathView.m in Sources */, 266 | 0131ED3C1A037767001C0DD8 /* AppDelegate.m in Sources */, 267 | 0187ACC31A087FF800094D67 /* DaiIndoxWindow.m in Sources */, 268 | 1C19DD321B79EB9300EFDBCB /* UIColor+MixColor.m in Sources */, 269 | 01D0C7781A0CB61C006AA033 /* DaiInboxDisplayLink.m in Sources */, 270 | 0187ACC61A08817F00094D67 /* DaiInboxViewController.m in Sources */, 271 | 0131ED5F1A037799001C0DD8 /* MainViewController.m in Sources */, 272 | 0131ED691A03794B001C0DD8 /* DaiInboxView.m in Sources */, 273 | 0131ED391A037767001C0DD8 /* main.m in Sources */, 274 | 0131ED661A037896001C0DD8 /* DaiInboxHUD.m in Sources */, 275 | ); 276 | runOnlyForDeploymentPostprocessing = 0; 277 | }; 278 | 0131ED481A037767001C0DD8 /* Sources */ = { 279 | isa = PBXSourcesBuildPhase; 280 | buildActionMask = 2147483647; 281 | files = ( 282 | 0131ED531A037767001C0DD8 /* DaiInboxHUDTests.m in Sources */, 283 | ); 284 | runOnlyForDeploymentPostprocessing = 0; 285 | }; 286 | /* End PBXSourcesBuildPhase section */ 287 | 288 | /* Begin PBXTargetDependency section */ 289 | 0131ED4E1A037767001C0DD8 /* PBXTargetDependency */ = { 290 | isa = PBXTargetDependency; 291 | target = 0131ED321A037767001C0DD8 /* DaiInboxHUD */; 292 | targetProxy = 0131ED4D1A037767001C0DD8 /* PBXContainerItemProxy */; 293 | }; 294 | /* End PBXTargetDependency section */ 295 | 296 | /* Begin XCBuildConfiguration section */ 297 | 0131ED541A037767001C0DD8 /* Debug */ = { 298 | isa = XCBuildConfiguration; 299 | buildSettings = { 300 | ALWAYS_SEARCH_USER_PATHS = NO; 301 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 302 | CLANG_CXX_LIBRARY = "libc++"; 303 | CLANG_ENABLE_MODULES = YES; 304 | CLANG_ENABLE_OBJC_ARC = YES; 305 | CLANG_WARN_BOOL_CONVERSION = YES; 306 | CLANG_WARN_CONSTANT_CONVERSION = YES; 307 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 308 | CLANG_WARN_EMPTY_BODY = YES; 309 | CLANG_WARN_ENUM_CONVERSION = YES; 310 | CLANG_WARN_INT_CONVERSION = YES; 311 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 312 | CLANG_WARN_UNREACHABLE_CODE = YES; 313 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 314 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 315 | COPY_PHASE_STRIP = NO; 316 | ENABLE_STRICT_OBJC_MSGSEND = YES; 317 | GCC_C_LANGUAGE_STANDARD = gnu99; 318 | GCC_DYNAMIC_NO_PIC = NO; 319 | GCC_OPTIMIZATION_LEVEL = 0; 320 | GCC_PREPROCESSOR_DEFINITIONS = ( 321 | "DEBUG=1", 322 | "$(inherited)", 323 | ); 324 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 325 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 326 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 327 | GCC_WARN_UNDECLARED_SELECTOR = YES; 328 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 329 | GCC_WARN_UNUSED_FUNCTION = YES; 330 | GCC_WARN_UNUSED_VARIABLE = YES; 331 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 332 | MTL_ENABLE_DEBUG_INFO = YES; 333 | ONLY_ACTIVE_ARCH = YES; 334 | SDKROOT = iphoneos; 335 | }; 336 | name = Debug; 337 | }; 338 | 0131ED551A037767001C0DD8 /* Release */ = { 339 | isa = XCBuildConfiguration; 340 | buildSettings = { 341 | ALWAYS_SEARCH_USER_PATHS = NO; 342 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 343 | CLANG_CXX_LIBRARY = "libc++"; 344 | CLANG_ENABLE_MODULES = YES; 345 | CLANG_ENABLE_OBJC_ARC = YES; 346 | CLANG_WARN_BOOL_CONVERSION = YES; 347 | CLANG_WARN_CONSTANT_CONVERSION = YES; 348 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 349 | CLANG_WARN_EMPTY_BODY = YES; 350 | CLANG_WARN_ENUM_CONVERSION = YES; 351 | CLANG_WARN_INT_CONVERSION = YES; 352 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 353 | CLANG_WARN_UNREACHABLE_CODE = YES; 354 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 355 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 356 | COPY_PHASE_STRIP = YES; 357 | ENABLE_NS_ASSERTIONS = NO; 358 | ENABLE_STRICT_OBJC_MSGSEND = YES; 359 | GCC_C_LANGUAGE_STANDARD = gnu99; 360 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 361 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 362 | GCC_WARN_UNDECLARED_SELECTOR = YES; 363 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 364 | GCC_WARN_UNUSED_FUNCTION = YES; 365 | GCC_WARN_UNUSED_VARIABLE = YES; 366 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 367 | MTL_ENABLE_DEBUG_INFO = NO; 368 | SDKROOT = iphoneos; 369 | VALIDATE_PRODUCT = YES; 370 | }; 371 | name = Release; 372 | }; 373 | 0131ED571A037767001C0DD8 /* Debug */ = { 374 | isa = XCBuildConfiguration; 375 | buildSettings = { 376 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 377 | INFOPLIST_FILE = DaiInboxHUD/Info.plist; 378 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 379 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 380 | PRODUCT_NAME = "$(TARGET_NAME)"; 381 | }; 382 | name = Debug; 383 | }; 384 | 0131ED581A037767001C0DD8 /* Release */ = { 385 | isa = XCBuildConfiguration; 386 | buildSettings = { 387 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 388 | INFOPLIST_FILE = DaiInboxHUD/Info.plist; 389 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 390 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 391 | PRODUCT_NAME = "$(TARGET_NAME)"; 392 | }; 393 | name = Release; 394 | }; 395 | 0131ED5A1A037767001C0DD8 /* Debug */ = { 396 | isa = XCBuildConfiguration; 397 | buildSettings = { 398 | BUNDLE_LOADER = "$(TEST_HOST)"; 399 | FRAMEWORK_SEARCH_PATHS = ( 400 | "$(SDKROOT)/Developer/Library/Frameworks", 401 | "$(inherited)", 402 | ); 403 | GCC_PREPROCESSOR_DEFINITIONS = ( 404 | "DEBUG=1", 405 | "$(inherited)", 406 | ); 407 | INFOPLIST_FILE = DaiInboxHUDTests/Info.plist; 408 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 409 | PRODUCT_NAME = "$(TARGET_NAME)"; 410 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DaiInboxHUD.app/DaiInboxHUD"; 411 | }; 412 | name = Debug; 413 | }; 414 | 0131ED5B1A037767001C0DD8 /* Release */ = { 415 | isa = XCBuildConfiguration; 416 | buildSettings = { 417 | BUNDLE_LOADER = "$(TEST_HOST)"; 418 | FRAMEWORK_SEARCH_PATHS = ( 419 | "$(SDKROOT)/Developer/Library/Frameworks", 420 | "$(inherited)", 421 | ); 422 | INFOPLIST_FILE = DaiInboxHUDTests/Info.plist; 423 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 424 | PRODUCT_NAME = "$(TARGET_NAME)"; 425 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DaiInboxHUD.app/DaiInboxHUD"; 426 | }; 427 | name = Release; 428 | }; 429 | /* End XCBuildConfiguration section */ 430 | 431 | /* Begin XCConfigurationList section */ 432 | 0131ED2E1A037767001C0DD8 /* Build configuration list for PBXProject "DaiInboxHUD" */ = { 433 | isa = XCConfigurationList; 434 | buildConfigurations = ( 435 | 0131ED541A037767001C0DD8 /* Debug */, 436 | 0131ED551A037767001C0DD8 /* Release */, 437 | ); 438 | defaultConfigurationIsVisible = 0; 439 | defaultConfigurationName = Release; 440 | }; 441 | 0131ED561A037767001C0DD8 /* Build configuration list for PBXNativeTarget "DaiInboxHUD" */ = { 442 | isa = XCConfigurationList; 443 | buildConfigurations = ( 444 | 0131ED571A037767001C0DD8 /* Debug */, 445 | 0131ED581A037767001C0DD8 /* Release */, 446 | ); 447 | defaultConfigurationIsVisible = 0; 448 | defaultConfigurationName = Release; 449 | }; 450 | 0131ED591A037767001C0DD8 /* Build configuration list for PBXNativeTarget "DaiInboxHUDTests" */ = { 451 | isa = XCConfigurationList; 452 | buildConfigurations = ( 453 | 0131ED5A1A037767001C0DD8 /* Debug */, 454 | 0131ED5B1A037767001C0DD8 /* Release */, 455 | ); 456 | defaultConfigurationIsVisible = 0; 457 | defaultConfigurationName = Release; 458 | }; 459 | /* End XCConfigurationList section */ 460 | }; 461 | rootObject = 0131ED2B1A037767001C0DD8 /* Project object */; 462 | } 463 | --------------------------------------------------------------------------------