From 67718e7baeccce2321cea0026bde319cd94b695d Mon Sep 17 00:00:00 2001 From: Nick Velloff Date: Fri, 29 Apr 2016 23:50:02 -0700 Subject: [PATCH] optional colors, optimize --- .../project.pbxproj | 310 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../GridLogo-example/AppDelegate.swift | 46 +++ .../AppIcon.appiconset/Contents.json | 68 ++++ .../Base.lproj/LaunchScreen.storyboard | 27 ++ .../Base.lproj/Main.storyboard | 26 ++ .../GridLogo-example/Info.plist | 47 +++ .../GridLogo-example/ViewController.swift | 75 +++++ GridLogo.xcodeproj/project.pbxproj | 4 - GridLogo/GridAnimatedLogo.swift | 65 ++-- GridLogo/GridLogo.swift | 26 -- 11 files changed, 634 insertions(+), 67 deletions(-) create mode 100644 Example/GridLogo-example/GridLogo-example.xcodeproj/project.pbxproj create mode 100644 Example/GridLogo-example/GridLogo-example.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 Example/GridLogo-example/GridLogo-example/AppDelegate.swift create mode 100644 Example/GridLogo-example/GridLogo-example/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Example/GridLogo-example/GridLogo-example/Base.lproj/LaunchScreen.storyboard create mode 100644 Example/GridLogo-example/GridLogo-example/Base.lproj/Main.storyboard create mode 100644 Example/GridLogo-example/GridLogo-example/Info.plist create mode 100644 Example/GridLogo-example/GridLogo-example/ViewController.swift delete mode 100644 GridLogo/GridLogo.swift diff --git a/Example/GridLogo-example/GridLogo-example.xcodeproj/project.pbxproj b/Example/GridLogo-example/GridLogo-example.xcodeproj/project.pbxproj new file mode 100644 index 0000000..7027aef --- /dev/null +++ b/Example/GridLogo-example/GridLogo-example.xcodeproj/project.pbxproj @@ -0,0 +1,310 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 76D9B92D1CD47391001A8ADF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76D9B92C1CD47391001A8ADF /* AppDelegate.swift */; }; + 76D9B92F1CD47391001A8ADF /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76D9B92E1CD47391001A8ADF /* ViewController.swift */; }; + 76D9B9321CD47391001A8ADF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 76D9B9301CD47391001A8ADF /* Main.storyboard */; }; + 76D9B9341CD47391001A8ADF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 76D9B9331CD47391001A8ADF /* Assets.xcassets */; }; + 76D9B9371CD47391001A8ADF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 76D9B9351CD47391001A8ADF /* LaunchScreen.storyboard */; }; + 76D9B9421CD4747E001A8ADF /* GridAnimatedLogo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76D9B93F1CD4747E001A8ADF /* GridAnimatedLogo.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 76D9B9291CD47391001A8ADF /* GridLogo-Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "GridLogo-Example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 76D9B92C1CD47391001A8ADF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 76D9B92E1CD47391001A8ADF /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 76D9B9311CD47391001A8ADF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 76D9B9331CD47391001A8ADF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 76D9B9361CD47391001A8ADF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 76D9B9381CD47391001A8ADF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 76D9B93F1CD4747E001A8ADF /* GridAnimatedLogo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GridAnimatedLogo.swift; sourceTree = ""; }; + 76D9B9401CD4747E001A8ADF /* GridLogo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GridLogo.h; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 76D9B9261CD47391001A8ADF /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 76D9B9201CD47391001A8ADF = { + isa = PBXGroup; + children = ( + 76D9B92B1CD47391001A8ADF /* GridLogo-Example */, + 76D9B93E1CD4739E001A8ADF /* GridLogo */, + 76D9B92A1CD47391001A8ADF /* Products */, + ); + sourceTree = ""; + }; + 76D9B92A1CD47391001A8ADF /* Products */ = { + isa = PBXGroup; + children = ( + 76D9B9291CD47391001A8ADF /* GridLogo-Example.app */, + ); + name = Products; + sourceTree = ""; + }; + 76D9B92B1CD47391001A8ADF /* GridLogo-Example */ = { + isa = PBXGroup; + children = ( + 76D9B92C1CD47391001A8ADF /* AppDelegate.swift */, + 76D9B92E1CD47391001A8ADF /* ViewController.swift */, + 76D9B9301CD47391001A8ADF /* Main.storyboard */, + 76D9B9331CD47391001A8ADF /* Assets.xcassets */, + 76D9B9351CD47391001A8ADF /* LaunchScreen.storyboard */, + 76D9B9381CD47391001A8ADF /* Info.plist */, + ); + path = "GridLogo-Example"; + sourceTree = ""; + }; + 76D9B93E1CD4739E001A8ADF /* GridLogo */ = { + isa = PBXGroup; + children = ( + 76D9B93F1CD4747E001A8ADF /* GridAnimatedLogo.swift */, + 76D9B9401CD4747E001A8ADF /* GridLogo.h */, + ); + name = GridLogo; + path = ../../GridLogo; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 76D9B9281CD47391001A8ADF /* GridLogo-Example */ = { + isa = PBXNativeTarget; + buildConfigurationList = 76D9B93B1CD47391001A8ADF /* Build configuration list for PBXNativeTarget "GridLogo-Example" */; + buildPhases = ( + 76D9B9251CD47391001A8ADF /* Sources */, + 76D9B9261CD47391001A8ADF /* Frameworks */, + 76D9B9271CD47391001A8ADF /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "GridLogo-Example"; + productName = "GridLogo-Example"; + productReference = 76D9B9291CD47391001A8ADF /* GridLogo-Example.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 76D9B9211CD47391001A8ADF /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0730; + LastUpgradeCheck = 0730; + ORGANIZATIONNAME = "The Grid"; + TargetAttributes = { + 76D9B9281CD47391001A8ADF = { + CreatedOnToolsVersion = 7.3; + }; + }; + }; + buildConfigurationList = 76D9B9241CD47391001A8ADF /* Build configuration list for PBXProject "GridLogo-Example" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 76D9B9201CD47391001A8ADF; + productRefGroup = 76D9B92A1CD47391001A8ADF /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 76D9B9281CD47391001A8ADF /* GridLogo-Example */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 76D9B9271CD47391001A8ADF /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 76D9B9371CD47391001A8ADF /* LaunchScreen.storyboard in Resources */, + 76D9B9341CD47391001A8ADF /* Assets.xcassets in Resources */, + 76D9B9321CD47391001A8ADF /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 76D9B9251CD47391001A8ADF /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 76D9B92F1CD47391001A8ADF /* ViewController.swift in Sources */, + 76D9B92D1CD47391001A8ADF /* AppDelegate.swift in Sources */, + 76D9B9421CD4747E001A8ADF /* GridAnimatedLogo.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 76D9B9301CD47391001A8ADF /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 76D9B9311CD47391001A8ADF /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 76D9B9351CD47391001A8ADF /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 76D9B9361CD47391001A8ADF /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 76D9B9391CD47391001A8ADF /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + 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_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + 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 = 9.3; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 76D9B93A1CD47391001A8ADF /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + 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_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + 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 = 9.3; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 76D9B93C1CD47391001A8ADF /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = "GridLogo-Example/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "io.thegrid.GridLogo-Example"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 76D9B93D1CD47391001A8ADF /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = "GridLogo-Example/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "io.thegrid.GridLogo-Example"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 76D9B9241CD47391001A8ADF /* Build configuration list for PBXProject "GridLogo-Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 76D9B9391CD47391001A8ADF /* Debug */, + 76D9B93A1CD47391001A8ADF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 76D9B93B1CD47391001A8ADF /* Build configuration list for PBXNativeTarget "GridLogo-Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 76D9B93C1CD47391001A8ADF /* Debug */, + 76D9B93D1CD47391001A8ADF /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 76D9B9211CD47391001A8ADF /* Project object */; +} diff --git a/Example/GridLogo-example/GridLogo-example.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Example/GridLogo-example/GridLogo-example.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..38a6e15 --- /dev/null +++ b/Example/GridLogo-example/GridLogo-example.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Example/GridLogo-example/GridLogo-example/AppDelegate.swift b/Example/GridLogo-example/GridLogo-example/AppDelegate.swift new file mode 100644 index 0000000..3a312a3 --- /dev/null +++ b/Example/GridLogo-example/GridLogo-example/AppDelegate.swift @@ -0,0 +1,46 @@ +// +// AppDelegate.swift +// GridLogo-Example +// +// Created by Nicholas Velloff on 4/29/16. +// Copyright © 2016 The Grid. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(application: UIApplication) { + // 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 throttle down OpenGL ES frame rates. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(application: UIApplication) { + // 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. + } + + func applicationWillEnterForeground(application: UIApplication) { + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(application: UIApplication) { + // 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. + } + + func applicationWillTerminate(application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/Example/GridLogo-example/GridLogo-example/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example/GridLogo-example/GridLogo-example/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..36d2c80 --- /dev/null +++ b/Example/GridLogo-example/GridLogo-example/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/Example/GridLogo-example/GridLogo-example/Base.lproj/LaunchScreen.storyboard b/Example/GridLogo-example/GridLogo-example/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..2e721e1 --- /dev/null +++ b/Example/GridLogo-example/GridLogo-example/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/GridLogo-example/GridLogo-example/Base.lproj/Main.storyboard b/Example/GridLogo-example/GridLogo-example/Base.lproj/Main.storyboard new file mode 100644 index 0000000..dd531d9 --- /dev/null +++ b/Example/GridLogo-example/GridLogo-example/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/GridLogo-example/GridLogo-example/Info.plist b/Example/GridLogo-example/GridLogo-example/Info.plist new file mode 100644 index 0000000..40c6215 --- /dev/null +++ b/Example/GridLogo-example/GridLogo-example/Info.plist @@ -0,0 +1,47 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Example/GridLogo-example/GridLogo-example/ViewController.swift b/Example/GridLogo-example/GridLogo-example/ViewController.swift new file mode 100644 index 0000000..016041d --- /dev/null +++ b/Example/GridLogo-example/GridLogo-example/ViewController.swift @@ -0,0 +1,75 @@ +// +// ViewController.swift +// GridLogo-Example +// +// Created by Nicholas Velloff on 4/29/16. +// Copyright © 2016 The Grid. All rights reserved. +// + +import UIKit + +class ViewController: UIViewController { + + let logo: GridLogo + + required init?(coder aDecoder: NSCoder) { + let screenSize: CGRect = UIScreen.mainScreen().bounds + let mystic = screenSize.height/4 + + logo = GridLogo(mystic: mystic, duration: 30, lineWidth: 1, bgColor: UIColor.grayColor(), fgColor: UIColor.whiteColor()) + + super.init(coder: aDecoder) + } + + override func viewDidLoad() { + super.viewDidLoad() + + view.backgroundColor = UIColor.blackColor() + + let screenSize: CGRect = UIScreen.mainScreen().bounds + let screenWidth = screenSize.width + let screenHeight = screenSize.height + + logo.frame.offsetInPlace(dx: screenWidth/2, dy: screenHeight/2) + logo.frame.origin.x = screenWidth/2 + logo.frame.origin.y = screenHeight/2 + logo.transform = CGAffineTransformMakeRotation(CGFloat(-45).degreesToRadians) + + view.addSubview(logo) + logo.show() + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) { + coordinator.animateAlongsideTransition({ context in + self.logo.frame.origin.x = size.width/2 + self.logo.frame.origin.y = size.height/2 + }, completion: .None) + } +} + +extension Int { + var degreesToRadians: Double { return Double(self) * M_PI / 180 } + var radiansToDegrees: Double { return Double(self) * 180 / M_PI } +} + +extension Double { + var degreesToRadians: Double { return self * M_PI / 180 } + var radiansToDegrees: Double { return self * 180 / M_PI } +} + +extension CGFloat { + var doubleValue: Double { return Double(self) } + var degreesToRadians: CGFloat { return CGFloat(doubleValue * M_PI / 180) } + var radiansToDegrees: CGFloat { return CGFloat(doubleValue * 180 / M_PI) } +} + +extension Float { + var doubleValue: Double { return Double(self) } + var degreesToRadians: Float { return Float(doubleValue * M_PI / 180) } + var radiansToDegrees: Float { return Float(doubleValue * 180 / M_PI) } +} \ No newline at end of file diff --git a/GridLogo.xcodeproj/project.pbxproj b/GridLogo.xcodeproj/project.pbxproj index 2e729d2..680063e 100644 --- a/GridLogo.xcodeproj/project.pbxproj +++ b/GridLogo.xcodeproj/project.pbxproj @@ -10,7 +10,6 @@ 01F3780D1B3F13DA0028211B /* GridLogo.h in Headers */ = {isa = PBXBuildFile; fileRef = 01F3780C1B3F13DA0028211B /* GridLogo.h */; settings = {ATTRIBUTES = (Public, ); }; }; 01F378131B3F13DA0028211B /* GridLogo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01F378071B3F13DA0028211B /* GridLogo.framework */; }; 01F3781A1B3F13DA0028211B /* GridLogoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F378191B3F13DA0028211B /* GridLogoTests.swift */; }; - 01F378241B3F14300028211B /* GridLogo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F378231B3F14300028211B /* GridLogo.swift */; }; 01F3788C1B3F6E470028211B /* GridAnimatedLogo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F3788B1B3F6E470028211B /* GridAnimatedLogo.swift */; }; /* End PBXBuildFile section */ @@ -31,7 +30,6 @@ 01F378121B3F13DA0028211B /* GridLogoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GridLogoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 01F378181B3F13DA0028211B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 01F378191B3F13DA0028211B /* GridLogoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GridLogoTests.swift; sourceTree = ""; }; - 01F378231B3F14300028211B /* GridLogo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GridLogo.swift; sourceTree = ""; }; 01F3788B1B3F6E470028211B /* GridAnimatedLogo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GridAnimatedLogo.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -75,7 +73,6 @@ 01F378091B3F13DA0028211B /* Source */ = { isa = PBXGroup; children = ( - 01F378231B3F14300028211B /* GridLogo.swift */, 01F3788A1B3F69A40028211B /* Core */, 01F3780A1B3F13DA0028211B /* Supporting Files */, ); @@ -226,7 +223,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 01F378241B3F14300028211B /* GridLogo.swift in Sources */, 01F3788C1B3F6E470028211B /* GridAnimatedLogo.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/GridLogo/GridAnimatedLogo.swift b/GridLogo/GridAnimatedLogo.swift index 274aded..91d0dc0 100644 --- a/GridLogo/GridAnimatedLogo.swift +++ b/GridLogo/GridAnimatedLogo.swift @@ -8,7 +8,19 @@ import UIKit -public class AnimatedGridLogo: UIView { +extension CGSize { + func toInt() -> CGSize { + return CGSize(width: round(self.width), height: round(self.height)) + } +} + +extension CGPoint { + func toInt() -> CGPoint { + return CGPoint(x: round(self.x), y: round(self.y)) + } +} + +public class GridLogo: UIView { var mystic: CGFloat = 4 var turns = 9 @@ -52,43 +64,22 @@ public class AnimatedGridLogo: UIView { return animation }() - override init(frame: CGRect) { - super.init(frame: frame) - } - - public convenience init(mystic: CGFloat, duration: CFTimeInterval, lineWidth: CGFloat?) { - self.init(frame: CGRectZero) - self.mystic = mystic - self.duration = duration - self.repeatCount = 1 - self.reverses = false - self.lineWidth = lineWidth - setup() - } - - public convenience init(mystic: CGFloat, lineWidth: CGFloat?) { - self.init(frame: CGRectZero) - self.mystic = mystic - self.lineWidth = lineWidth - setup() + public init(mystic m: CGFloat, duration d: CFTimeInterval, lineWidth lw: CGFloat = 1, bgColor: UIColor = UIColor(red: 51/255, green: 51/255, blue: 48/255, alpha: 1), fgColor: UIColor = UIColor(red: 1, green: 246/255, blue: 153/255, alpha: 1)) { + super.init(frame: CGRectZero) + mystic = m + duration = d + lineWidth = lw + md = m + strokeRatio = CGFloat(md) / CGFloat(mystic) + userInteractionEnabled = false + addBackground(bgColor) + setupAnimation(fgColor) } required public init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } - - public override func didMoveToSuperview() { - super.didMoveToSuperview() - } - - func setup() { - self.md = CGFloat(mystic * mystic) - self.strokeRatio = CGFloat(md) / CGFloat(mystic) - self.userInteractionEnabled = false - addBackground() - setupAnimation() - } - + var logoPath: UIBezierPath { get{ self.curr = CGPoint.zero @@ -111,10 +102,10 @@ public class AnimatedGridLogo: UIView { } } - func setupAnimation() { + func setupAnimation(color: UIColor) { if fgLayer == nil { - let foreground = shapeLayerWithLogoPath(UIColor(red: 1, green: 246/255, blue: 153/255, alpha: 1), lineJoin: kCALineJoinMiter) + let foreground = shapeLayerWithLogoPath(color, lineJoin: kCALineJoinMiter) self.fgLayer = foreground self.layer.addSublayer(foreground) } @@ -189,9 +180,9 @@ public class AnimatedGridLogo: UIView { return shapeLayer } - func addBackground() { + func addBackground(color: UIColor) { if bgLayer == nil { - let background = shapeLayerWithLogoPath(UIColor(red: 51/255, green: 51/255, blue: 48/255, alpha: 1), lineJoin: kCALineJoinMiter) + let background = shapeLayerWithLogoPath(color, lineJoin: kCALineJoinMiter) self.bgLayer = background self.layer.addSublayer(background) } diff --git a/GridLogo/GridLogo.swift b/GridLogo/GridLogo.swift deleted file mode 100644 index 1c37423..0000000 --- a/GridLogo/GridLogo.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// Logo.swift -// The Grid iOS -// -// Created by Nicholas Velloff on 6/10/15. -// Copyright (c) 2015 Rituwall, Inc. All rights reserved. -// - - - -extension CGSize { - func toInt() -> CGSize { - return CGSize(width: round(self.width), height: round(self.height)) - } -} - -extension CGPoint { - func toInt() -> CGPoint { - return CGPoint(x: round(self.x), y: round(self.y)) - } -} - - -public func getGridLogo(mystic: CGFloat) -> AnimatedGridLogo { - return AnimatedGridLogo() -} \ No newline at end of file