From 52dee0c6d71b9f10635b7c188c8e2543c76fc0bb Mon Sep 17 00:00:00 2001 From: XcodeYang Date: Thu, 25 May 2017 10:55:28 +0800 Subject: [PATCH] init demo --- Demo/XYDebugView.xcodeproj/project.pbxproj | 343 +++++++++++++ .../contents.xcworkspacedata | 7 + Demo/XYDebugView/AppDelegate.h | 17 + Demo/XYDebugView/AppDelegate.m | 51 ++ .../AppIcon.appiconset/Contents.json | 68 +++ .../Base.lproj/LaunchScreen.storyboard | 27 + Demo/XYDebugView/Base.lproj/Main.storyboard | 313 ++++++++++++ Demo/XYDebugView/Info.plist | 45 ++ Demo/XYDebugView/ViewController.h | 15 + Demo/XYDebugView/ViewController.m | 63 +++ Demo/XYDebugView/main.m | 16 + XYDebugView/XYDebugViewManager.h | 17 + XYDebugView/XYDebugViewManager.m | 481 ++++++++++++++++++ 13 files changed, 1463 insertions(+) create mode 100644 Demo/XYDebugView.xcodeproj/project.pbxproj create mode 100644 Demo/XYDebugView.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 Demo/XYDebugView/AppDelegate.h create mode 100644 Demo/XYDebugView/AppDelegate.m create mode 100644 Demo/XYDebugView/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Demo/XYDebugView/Base.lproj/LaunchScreen.storyboard create mode 100644 Demo/XYDebugView/Base.lproj/Main.storyboard create mode 100644 Demo/XYDebugView/Info.plist create mode 100644 Demo/XYDebugView/ViewController.h create mode 100644 Demo/XYDebugView/ViewController.m create mode 100644 Demo/XYDebugView/main.m create mode 100644 XYDebugView/XYDebugViewManager.h create mode 100644 XYDebugView/XYDebugViewManager.m diff --git a/Demo/XYDebugView.xcodeproj/project.pbxproj b/Demo/XYDebugView.xcodeproj/project.pbxproj new file mode 100644 index 0000000..4f3f40b --- /dev/null +++ b/Demo/XYDebugView.xcodeproj/project.pbxproj @@ -0,0 +1,343 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 65758CA91ED5B41600A7738D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 65758CA81ED5B41600A7738D /* main.m */; }; + 65758CAC1ED5B41600A7738D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 65758CAB1ED5B41600A7738D /* AppDelegate.m */; }; + 65758CAF1ED5B41600A7738D /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 65758CAE1ED5B41600A7738D /* ViewController.m */; }; + 65758CB21ED5B41600A7738D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 65758CB01ED5B41600A7738D /* Main.storyboard */; }; + 65758CB41ED5B41600A7738D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 65758CB31ED5B41600A7738D /* Assets.xcassets */; }; + 65758CB71ED5B41600A7738D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 65758CB51ED5B41600A7738D /* LaunchScreen.storyboard */; }; + 65758CC41ED5B4CD00A7738D /* XYDebugViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 65758CC31ED5B4CD00A7738D /* XYDebugViewManager.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 65758CA41ED5B41600A7738D /* XYDebugView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = XYDebugView.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 65758CA81ED5B41600A7738D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 65758CAA1ED5B41600A7738D /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 65758CAB1ED5B41600A7738D /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 65758CAD1ED5B41600A7738D /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 65758CAE1ED5B41600A7738D /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 65758CB11ED5B41600A7738D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 65758CB31ED5B41600A7738D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 65758CB61ED5B41600A7738D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 65758CB81ED5B41600A7738D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 65758CC21ED5B4CD00A7738D /* XYDebugViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XYDebugViewManager.h; sourceTree = ""; }; + 65758CC31ED5B4CD00A7738D /* XYDebugViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XYDebugViewManager.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 65758CA11ED5B41600A7738D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 65758C9B1ED5B41600A7738D = { + isa = PBXGroup; + children = ( + 65758CA61ED5B41600A7738D /* XYDebugView */, + 65758CA51ED5B41600A7738D /* Products */, + ); + sourceTree = ""; + }; + 65758CA51ED5B41600A7738D /* Products */ = { + isa = PBXGroup; + children = ( + 65758CA41ED5B41600A7738D /* XYDebugView.app */, + ); + name = Products; + sourceTree = ""; + }; + 65758CA61ED5B41600A7738D /* XYDebugView */ = { + isa = PBXGroup; + children = ( + 65758CC11ED5B4CD00A7738D /* XYDebugView */, + 65758CAA1ED5B41600A7738D /* AppDelegate.h */, + 65758CAB1ED5B41600A7738D /* AppDelegate.m */, + 65758CAD1ED5B41600A7738D /* ViewController.h */, + 65758CAE1ED5B41600A7738D /* ViewController.m */, + 65758CB01ED5B41600A7738D /* Main.storyboard */, + 65758CB31ED5B41600A7738D /* Assets.xcassets */, + 65758CB51ED5B41600A7738D /* LaunchScreen.storyboard */, + 65758CB81ED5B41600A7738D /* Info.plist */, + 65758CA71ED5B41600A7738D /* Supporting Files */, + ); + path = XYDebugView; + sourceTree = ""; + }; + 65758CA71ED5B41600A7738D /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 65758CA81ED5B41600A7738D /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 65758CC11ED5B4CD00A7738D /* XYDebugView */ = { + isa = PBXGroup; + children = ( + 65758CC21ED5B4CD00A7738D /* XYDebugViewManager.h */, + 65758CC31ED5B4CD00A7738D /* XYDebugViewManager.m */, + ); + name = XYDebugView; + path = ../../XYDebugView; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 65758CA31ED5B41600A7738D /* XYDebugView */ = { + isa = PBXNativeTarget; + buildConfigurationList = 65758CBB1ED5B41600A7738D /* Build configuration list for PBXNativeTarget "XYDebugView" */; + buildPhases = ( + 65758CA01ED5B41600A7738D /* Sources */, + 65758CA11ED5B41600A7738D /* Frameworks */, + 65758CA21ED5B41600A7738D /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = XYDebugView; + productName = XYDebugView; + productReference = 65758CA41ED5B41600A7738D /* XYDebugView.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 65758C9C1ED5B41600A7738D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0830; + ORGANIZATIONNAME = XcodeYang; + TargetAttributes = { + 65758CA31ED5B41600A7738D = { + CreatedOnToolsVersion = 8.3.2; + DevelopmentTeam = H9J886PZ98; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 65758C9F1ED5B41600A7738D /* Build configuration list for PBXProject "XYDebugView" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 65758C9B1ED5B41600A7738D; + productRefGroup = 65758CA51ED5B41600A7738D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 65758CA31ED5B41600A7738D /* XYDebugView */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 65758CA21ED5B41600A7738D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 65758CB71ED5B41600A7738D /* LaunchScreen.storyboard in Resources */, + 65758CB41ED5B41600A7738D /* Assets.xcassets in Resources */, + 65758CB21ED5B41600A7738D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 65758CA01ED5B41600A7738D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 65758CAF1ED5B41600A7738D /* ViewController.m in Sources */, + 65758CAC1ED5B41600A7738D /* AppDelegate.m in Sources */, + 65758CC41ED5B4CD00A7738D /* XYDebugViewManager.m in Sources */, + 65758CA91ED5B41600A7738D /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 65758CB01ED5B41600A7738D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 65758CB11ED5B41600A7738D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 65758CB51ED5B41600A7738D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 65758CB61ED5B41600A7738D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 65758CB91ED5B41600A7738D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.3; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 65758CBA1ED5B41600A7738D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.3; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 65758CBC1ED5B41600A7738D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = H9J886PZ98; + INFOPLIST_FILE = XYDebugView/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = Daniel.XYDebugView; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = "77385128-ca56-4121-a84d-7263f8fe4c37"; + PROVISIONING_PROFILE_SPECIFIER = "chelun any app"; + }; + name = Debug; + }; + 65758CBD1ED5B41600A7738D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = H9J886PZ98; + INFOPLIST_FILE = XYDebugView/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = Daniel.XYDebugView; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = "77385128-ca56-4121-a84d-7263f8fe4c37"; + PROVISIONING_PROFILE_SPECIFIER = "chelun any app"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 65758C9F1ED5B41600A7738D /* Build configuration list for PBXProject "XYDebugView" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 65758CB91ED5B41600A7738D /* Debug */, + 65758CBA1ED5B41600A7738D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 65758CBB1ED5B41600A7738D /* Build configuration list for PBXNativeTarget "XYDebugView" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 65758CBC1ED5B41600A7738D /* Debug */, + 65758CBD1ED5B41600A7738D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 65758C9C1ED5B41600A7738D /* Project object */; +} diff --git a/Demo/XYDebugView.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Demo/XYDebugView.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..03c3a8c --- /dev/null +++ b/Demo/XYDebugView.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Demo/XYDebugView/AppDelegate.h b/Demo/XYDebugView/AppDelegate.h new file mode 100644 index 0000000..5ec6ffe --- /dev/null +++ b/Demo/XYDebugView/AppDelegate.h @@ -0,0 +1,17 @@ +// +// AppDelegate.h +// XYDebugView +// +// Created by XcodeYang on 24/05/2017. +// Copyright © 2017 XcodeYang. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/Demo/XYDebugView/AppDelegate.m b/Demo/XYDebugView/AppDelegate.m new file mode 100644 index 0000000..7c1a03b --- /dev/null +++ b/Demo/XYDebugView/AppDelegate.m @@ -0,0 +1,51 @@ +// +// AppDelegate.m +// XYDebugView +// +// Created by XcodeYang on 24/05/2017. +// Copyright © 2017 XcodeYang. All rights reserved. +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + + +- (void)applicationWillResignActive:(UIApplication *)application { + // 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. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. +} + + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // 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. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. +} + + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // 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. +} + + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + + +@end diff --git a/Demo/XYDebugView/Assets.xcassets/AppIcon.appiconset/Contents.json b/Demo/XYDebugView/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..36d2c80 --- /dev/null +++ b/Demo/XYDebugView/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Demo/XYDebugView/Base.lproj/LaunchScreen.storyboard b/Demo/XYDebugView/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..fdf3f97 --- /dev/null +++ b/Demo/XYDebugView/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Demo/XYDebugView/Base.lproj/Main.storyboard b/Demo/XYDebugView/Base.lproj/Main.storyboard new file mode 100644 index 0000000..417be72 --- /dev/null +++ b/Demo/XYDebugView/Base.lproj/Main.storyboard @@ -0,0 +1,313 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Demo/XYDebugView/Info.plist b/Demo/XYDebugView/Info.plist new file mode 100644 index 0000000..d052473 --- /dev/null +++ b/Demo/XYDebugView/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Demo/XYDebugView/ViewController.h b/Demo/XYDebugView/ViewController.h new file mode 100644 index 0000000..7f61692 --- /dev/null +++ b/Demo/XYDebugView/ViewController.h @@ -0,0 +1,15 @@ +// +// ViewController.h +// XYDebugView +// +// Created by XcodeYang on 24/05/2017. +// Copyright © 2017 XcodeYang. All rights reserved. +// + +#import + +@interface ViewController : UITableViewController + + +@end + diff --git a/Demo/XYDebugView/ViewController.m b/Demo/XYDebugView/ViewController.m new file mode 100644 index 0000000..268c667 --- /dev/null +++ b/Demo/XYDebugView/ViewController.m @@ -0,0 +1,63 @@ +// +// ViewController.m +// XYDebugView +// +// Created by XcodeYang on 24/05/2017. +// Copyright © 2017 XcodeYang. All rights reserved. +// + +#import "ViewController.h" +#import "XYDebugViewManager.h" + +@interface ViewController () + +@property (weak, nonatomic) IBOutlet UISwitch *debugSwitch; + +@end + +@implementation ViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + _debugSwitch.on = [XYDebugViewManager sharedInstance].isDebugging; +} + +#pragma mark - delegate + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + + if (indexPath.section == 1) { + switch (indexPath.row) { + case 0: [self showAlert]; break; + case 1: [self showSheet]; break; + case 2: [self showActivity]; break; + default: break; + } + } +} + +- (void)scrollViewDidScroll:(UIScrollView *)scrollView { + [self.view endEditing:YES]; +} + +#pragma mark - action +- (void)showAlert { + [[[UIAlertView alloc] initWithTitle:@"Alert Title" message:@"ready to debug alert view's layout" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Sure", nil] show]; +} + +- (void)showSheet { + [[[UIActionSheet alloc] initWithTitle:@"Sheet Title" delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Destructive" otherButtonTitles:@"Others", nil] showInView:self.view]; +} + +- (void)showActivity { + UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[@"Activity Title",[NSURL URLWithString:@"https://www.baidu.com"]] applicationActivities:nil]; + [self presentViewController:activityVC animated:YES completion:nil]; +} + +- (IBAction)switchChanged:(UISwitch *)sender { + [XYDebugViewManager sharedInstance].isDebugging = sender.on; +} + +@end diff --git a/Demo/XYDebugView/main.m b/Demo/XYDebugView/main.m new file mode 100644 index 0000000..30db138 --- /dev/null +++ b/Demo/XYDebugView/main.m @@ -0,0 +1,16 @@ +// +// main.m +// XYDebugView +// +// Created by XcodeYang on 24/05/2017. +// Copyright © 2017 XcodeYang. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/XYDebugView/XYDebugViewManager.h b/XYDebugView/XYDebugViewManager.h new file mode 100644 index 0000000..c939099 --- /dev/null +++ b/XYDebugView/XYDebugViewManager.h @@ -0,0 +1,17 @@ +// +// XYDebugViewManager.h +// QueryViolations +// +// Created by XcodeYang on 02/05/2017. +// Copyright © 2017 eclicks. All rights reserved. +// + +#import + +@interface XYDebugViewManager : NSObject + +@property (nonatomic, assign) BOOL isDebugging; + ++ (XYDebugViewManager *)sharedInstance; + +@end diff --git a/XYDebugView/XYDebugViewManager.m b/XYDebugView/XYDebugViewManager.m new file mode 100644 index 0000000..9f181db --- /dev/null +++ b/XYDebugView/XYDebugViewManager.m @@ -0,0 +1,481 @@ +// +// XYDebugViewManager.m +// QueryViolations +// +// Created by XcodeYang on 02/05/2017. +// Copyright © 2017 eclicks. All rights reserved. +// + +#import "XYDebugViewManager.h" +#import + +#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width +#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height + +#pragma mark - UIColor random + +@interface UIColor (Random) ++ (UIColor *)randomColorWithAlpha:(CGFloat)alpha; +@end + +@implementation UIColor (Random) ++ (UIColor *)randomColorWithAlpha:(CGFloat)alpha +{ + + return [UIColor colorWithRed:(arc4random()%155+100)/255.0 + green:(arc4random()%155+100)/255.0 + blue:(arc4random()%155+100)/255.0 + alpha:alpha]; +} +@end + +#pragma mark - CloneView +@interface CloneView : UIView +@property(nonatomic, weak) UIView *srcView; ++ (CloneView *)cloneWith:(UIView *)view; +@end + +@implementation CloneView ++ (CloneView *)cloneWith:(UIView *)view{ + return [[CloneView alloc] initWithCopyView:view]; +} +- (instancetype)initWithCopyView:(UIView *)srcView{ + self = [super initWithFrame:srcView.frame]; + if (self) { + self.srcView = srcView; + self.backgroundColor = [UIColor randomColorWithAlpha:0.6]; + } + return self; +} +- (void)drawRect:(CGRect)rect{ + NSMutableArray *mArr = self.srcView.layer.sublayers.mutableCopy; + for (UIView *subview in self.srcView.subviews) { + if ([mArr containsObject:subview.layer]) { + [mArr removeObject:subview.layer]; + } + } + CALayer *newLayer = [CALayer layer]; + newLayer.contents = self.srcView.layer.contents; + newLayer.frame = self.srcView.layer.frame; + + for (CALayer *sublayer in mArr) { + CALayer *newSub = [[CALayer alloc] initWithLayer:sublayer]; + newSub.frame = sublayer.frame; + [newLayer addSublayer:newSub]; + } + [newLayer renderInContext:UIGraphicsGetCurrentContext()]; +} +@end + +#pragma mark - UIView runtime 添加属性 + +const static char * DebugStoreUIViewBackColor = "DebugStoreUIViewBackColor"; +const static char * DebugHasStoreUIViewBackColor = "DebugHasStoreUIViewBackColor"; +const static char * DebugCloneView = "DebugCloneView"; +const static char * DebugCloneLayer = "DebugCloneLayer"; +const static char * DebugColorSublayer = "DebugColorSublayer"; + + +@interface UIView (DebugStoreUIViewBackColor) + +@property (nonatomic, strong) UIColor *debugStoreOrginalColor; +@property (nonatomic, assign) BOOL hasStoreDebugColor; +@property (nonatomic, strong, readonly) CALayer *debugColorSublayer; +@property (nonatomic, strong, readonly) CloneView *cloneView; +@property (nonatomic, strong, readonly) CALayer *cloneLayer; +@property (nonatomic, copy, readonly) NSArray *debuRecurrenceAllSubviews; + +@end + +@implementation UIView (DebugStoreUIViewBackColor) + +- (void)setDebugStoreOrginalColor:(UIColor *)debugStoreOrginalColor +{ + if ([debugStoreOrginalColor isKindOfClass:[UIColor class]] && debugStoreOrginalColor) { + objc_setAssociatedObject(self, DebugStoreUIViewBackColor, debugStoreOrginalColor, OBJC_ASSOCIATION_RETAIN); + } +} + +- (UIColor *)debugStoreOrginalColor +{ + id obj = objc_getAssociatedObject(self, DebugStoreUIViewBackColor); + if ([obj isKindOfClass:[UIColor class]]) { + return (UIColor *)obj; + } + return nil; +} + +- (CALayer *)debugColorSublayer +{ + CALayer *obj = objc_getAssociatedObject(self, DebugColorSublayer); + if ([obj isKindOfClass:[CALayer class]] && obj) { + obj.frame = self.bounds; + return obj; + } + obj = [[CALayer alloc] init]; + obj.borderColor = [[UIColor redColor] colorWithAlphaComponent:0.2].CGColor; + obj.borderWidth = 1/[UIScreen mainScreen].scale; + objc_setAssociatedObject(self, DebugColorSublayer, obj, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + return [self debugColorSublayer]; +} + +- (CloneView *)cloneView +{ + CloneView *obj = objc_getAssociatedObject(self, DebugCloneView); + if ([obj isKindOfClass:[CloneView class]] && obj) { + return obj; + } + obj = [CloneView cloneWith:self]; + objc_setAssociatedObject(self, DebugCloneView, obj, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + return [self cloneView]; +} + +- (CALayer *)cloneLayer +{ + CALayer *obj = objc_getAssociatedObject(self, DebugCloneLayer); + if ([obj isKindOfClass:[CALayer class]] && obj) { + return obj; + } + obj = [CALayer layer]; + obj.contents = self.layer.contents; + objc_setAssociatedObject(self, DebugCloneLayer, obj, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + return [self cloneLayer]; +} + +- (void)setHasStoreDebugColor:(BOOL)hasStoreDebugColor +{ + objc_setAssociatedObject(self, DebugHasStoreUIViewBackColor, @(hasStoreDebugColor), OBJC_ASSOCIATION_ASSIGN); +} + +- (BOOL)hasStoreDebugColor +{ + id obj = objc_getAssociatedObject(self, DebugHasStoreUIViewBackColor); + return [obj boolValue]; +} + +- (NSArray *)debuRecurrenceAllSubviews +{ + NSMutableArray *all = @[].mutableCopy; + void (^getSubViewsBlock)(UIView *current) = ^(UIView *current){ + [all addObject:current]; + for (UIView *sub in current.subviews) { + [all addObjectsFromArray:[sub debuRecurrenceAllSubviews]]; + } + }; + getSubViewsBlock(self); + return [NSArray arrayWithArray:all]; +} + +@end + +#pragma mark - DebugSlider + +@interface DebugSlider : UIView +@property void (^touchMoveBlock)(float percent); +@property void (^touchEndBlock)(); +@end + +@implementation DebugSlider + +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event +{ + UITouch *touch = [touches anyObject]; + CGPoint point = [touch locationInView:self]; + float percent = point.y / self.frame.size.height; + percent = percent<0 ? percent : (percent>1 ? 1:percent); + !_touchMoveBlock ?: _touchMoveBlock(percent); +} + +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event +{ + !_touchEndBlock ?: _touchEndBlock(); +} + +@end + +#pragma mark - DebugWindow + +@interface DebugWindow : UIWindow + +@property (nonatomic, weak) XYDebugViewManager *frameManager; + +@property (nonatomic, weak) UIView *souceView; + +@property (nonatomic, strong) UIButton *button; +@property (nonatomic, strong) DebugSlider *slider; +@property (nonatomic, strong) UIScrollView *scrollView; +@property (nonatomic, strong) NSMutableArray * debugLayers; +@end + +@implementation DebugWindow + +- (instancetype)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + _button = [UIButton buttonWithType:UIButtonTypeCustom]; + [_button setTitle:@"tap statusbar to refresh debugging..." forState:UIControlStateNormal]; + _button.backgroundColor = [UIColor redColor]; + _button.frame = CGRectMake(0, 0, SCREEN_WIDTH, 20); + _button.titleLabel.font = [UIFont systemFontOfSize:11]; + _button.layer.zPosition = MAXFLOAT; + + _scrollView = [[UIScrollView alloc] initWithFrame:self.bounds]; + _scrollView.layer.zPosition = -MAXFLOAT; + _scrollView.contentSize = CGSizeMake(SCREEN_WIDTH*2,SCREEN_HEIGHT*2); + _scrollView.contentOffset = CGPointMake(SCREEN_WIDTH/2.0, SCREEN_HEIGHT/2.0); + _scrollView.backgroundColor = [UIColor whiteColor]; + _scrollView.hidden = YES; + CATransform3D transform = CATransform3DIdentity; + transform.m34 = -1.0 / 500; + _scrollView.layer.sublayerTransform = transform; + + _slider = [[DebugSlider alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-30, 40, 20, SCREEN_HEIGHT-40*2)]; + _slider.backgroundColor = [[UIColor greenColor] colorWithAlphaComponent:0.3]; + _slider.hidden = YES; + + typeof(self) weakSelf = self; + _slider.touchMoveBlock = ^(float percent) { + [weakSelf showDifferentLayers:percent]; + }; + _slider.touchEndBlock = ^{ + [weakSelf showAllLayer]; + }; + + [self addSubview:_scrollView]; + [self addSubview:_button]; + [self addSubview:_slider]; + self.backgroundColor = [UIColor clearColor]; + self.debugLayers = @[].mutableCopy; + self.layer.masksToBounds = YES; + } + return self; +} + +- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event +{ + if (self.userInteractionEnabled==NO || self.hidden==YES || self.alpha<=0.01) { + return nil; + } else if (![self pointInside:point withEvent:event]) { + return nil; + } else if (_frameManager.isDebugging) { + if (CGRectContainsPoint(_button.frame,point)) { + return _button; + } else if (CGRectContainsPoint(_slider.frame,point) && _souceView) { + return _slider; + } else if (CGRectContainsPoint(_scrollView.frame,point) && _souceView) { + return _scrollView; + } + return nil; + } + return nil; +} + +- (void)setSouceView:(UIView *)souceView +{ + _souceView = souceView; + if (_souceView == nil) { + [[self.debugLayers copy] makeObjectsPerformSelector:@selector(removeFromSuperlayer)]; + self.scrollView.hidden = YES; + self.slider.hidden = YES; + } else { + self.scrollView.contentOffset = CGPointMake(SCREEN_WIDTH/2.0, SCREEN_HEIGHT/2.0); + [self scrollViewAddLayersInView:_souceView layerLevel:0 index:0]; + self.scrollView.hidden = NO; + self.scrollView.contentOffset = CGPointMake(SCREEN_WIDTH/2.0, SCREEN_HEIGHT/2.0); + self.slider.hidden = NO; + } +} + +- (void)scrollViewAddLayersInView:(UIView *)view layerLevel:(CGFloat)layerLevel index:(NSUInteger)index +{ + if ([view isKindOfClass:[UIView class]] && view) { + if (view.superview) { + UIView *cloneView = view.cloneView; + cloneView.layer.zPosition = -500 + (layerLevel*60+index*5); + cloneView.layer.masksToBounds = YES; + + CGRect frame = [view.superview convertRect:view.frame toView:_souceView]; + frame.origin = CGPointMake(CGRectGetMinX(frame)+SCREEN_WIDTH/2.f, CGRectGetMinY(frame)+SCREEN_HEIGHT/2.f); + cloneView.layer.frame = frame; + cloneView.layer.opacity = 0.8; + [self.debugLayers addObject:cloneView.layer]; + [self.scrollView.layer addSublayer:cloneView.layer]; + } + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [view.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + [self scrollViewAddLayersInView:obj layerLevel:layerLevel+1 index:idx]; + }]; + }); + } +} + +- (void)showDifferentLayers:(float)percent +{ + CGFloat positionMax = self.debugLayers.firstObject.zPosition; + CGFloat positionMin = positionMax; + for (CALayer *layer in self.debugLayers) { + if (layer.zPosition >= positionMax) { + positionMax = layer.zPosition; + } + if (layer.zPosition <= positionMin) { + positionMin = layer.zPosition; + } + } + // 分成20节,每节为5 + CGFloat gap = (positionMax - positionMin)/20.f; + + // 每节为5,计算当前处于那一节的layer层显示 + float num = ceil((percent * 100)/5.f); + + CGFloat upRange = positionMin + gap*num; + CGFloat dowmRange = positionMin + gap*(num-1); + + for (CALayer *layer in self.debugLayers) { + layer.opacity = (layer.zPosition>upRange || layer.zPosition* allViews = parentView.debuRecurrenceAllSubviews.mutableCopy; + // 移除第一个view(window) + [allViews removeObjectAtIndex:0]; + + if (shouldRecoverBackColor) { + // 回复原貌 + for (UIView *subview in allViews) { + if (!subview.hasStoreDebugColor) { return; } + subview.backgroundColor = subview.debugStoreOrginalColor ?: [UIColor clearColor]; + subview.hasStoreDebugColor = NO; + subview.layer.borderWidth = CGFLOAT_MIN; + if (subview.debugColorSublayer.superlayer) { + [subview.debugColorSublayer removeFromSuperlayer]; + } + } + } else { + // 追加debug + for (UIView *subview in allViews) { + + if (subview.hasStoreDebugColor || subview==_assistiveWindow.button) { + return; + } + subview.debugStoreOrginalColor = subview.backgroundColor; + subview.hasStoreDebugColor = YES; + if (!CGRectEqualToRect(subview.bounds, [UIScreen mainScreen].bounds)) { + subview.backgroundColor = [UIColor randomColorWithAlpha:0.3]; + } + + // 添加view的frame边框 + if (!subview.debugColorSublayer.superlayer) { + [subview.layer addSublayer:subview.debugColorSublayer]; + } + } + } +} + +@end