diff --git a/SquareCrop/SquareCrop.xcodeproj/project.pbxproj b/SquareCrop/SquareCrop.xcodeproj/project.pbxproj new file mode 100644 index 0000000..edac90d --- /dev/null +++ b/SquareCrop/SquareCrop.xcodeproj/project.pbxproj @@ -0,0 +1,451 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + A7896513197E66CE00855AC4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A7896512197E66CE00855AC4 /* main.m */; }; + A7896516197E66CE00855AC4 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A7896515197E66CE00855AC4 /* AppDelegate.m */; }; + A7896519197E66CE00855AC4 /* SquareCrop.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = A7896517197E66CE00855AC4 /* SquareCrop.xcdatamodeld */; }; + A789651C197E66CE00855AC4 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A789651B197E66CE00855AC4 /* ViewController.m */; }; + A789651F197E66CE00855AC4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A789651D197E66CE00855AC4 /* Main.storyboard */; }; + A7896521197E66CE00855AC4 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A7896520197E66CE00855AC4 /* Images.xcassets */; }; + A789652D197E66CE00855AC4 /* SquareCropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A789652C197E66CE00855AC4 /* SquareCropTests.m */; }; + A7896537197E66F600855AC4 /* Image.jpg in Resources */ = {isa = PBXBuildFile; fileRef = A7896536197E66F600855AC4 /* Image.jpg */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + A7896527197E66CE00855AC4 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = A7896505197E66CE00855AC4 /* Project object */; + proxyType = 1; + remoteGlobalIDString = A789650C197E66CE00855AC4; + remoteInfo = SquareCrop; + }; + A7896538197E6C5000855AC4 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = A7896505197E66CE00855AC4 /* Project object */; + proxyType = 1; + remoteGlobalIDString = A789650C197E66CE00855AC4; + remoteInfo = SquareCrop; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + A789650D197E66CE00855AC4 /* SquareCrop.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SquareCrop.app; sourceTree = BUILT_PRODUCTS_DIR; }; + A7896511197E66CE00855AC4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + A7896512197E66CE00855AC4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + A7896514197E66CE00855AC4 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + A7896515197E66CE00855AC4 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + A7896518197E66CE00855AC4 /* SquareCrop.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = SquareCrop.xcdatamodel; sourceTree = ""; }; + A789651A197E66CE00855AC4 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + A789651B197E66CE00855AC4 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + A789651E197E66CE00855AC4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + A7896520197E66CE00855AC4 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + A7896526197E66CE00855AC4 /* SquareCropTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SquareCropTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + A789652B197E66CE00855AC4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + A789652C197E66CE00855AC4 /* SquareCropTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SquareCropTests.m; sourceTree = ""; }; + A7896536197E66F600855AC4 /* Image.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = Image.jpg; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + A789650A197E66CE00855AC4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A7896523197E66CE00855AC4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + A7896504197E66CE00855AC4 = { + isa = PBXGroup; + children = ( + A789650F197E66CE00855AC4 /* SquareCrop */, + A7896529197E66CE00855AC4 /* SquareCropTests */, + A789650E197E66CE00855AC4 /* Products */, + ); + sourceTree = ""; + }; + A789650E197E66CE00855AC4 /* Products */ = { + isa = PBXGroup; + children = ( + A789650D197E66CE00855AC4 /* SquareCrop.app */, + A7896526197E66CE00855AC4 /* SquareCropTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + A789650F197E66CE00855AC4 /* SquareCrop */ = { + isa = PBXGroup; + children = ( + A7896536197E66F600855AC4 /* Image.jpg */, + A7896514197E66CE00855AC4 /* AppDelegate.h */, + A7896515197E66CE00855AC4 /* AppDelegate.m */, + A789651A197E66CE00855AC4 /* ViewController.h */, + A789651B197E66CE00855AC4 /* ViewController.m */, + A789651D197E66CE00855AC4 /* Main.storyboard */, + A7896520197E66CE00855AC4 /* Images.xcassets */, + A7896517197E66CE00855AC4 /* SquareCrop.xcdatamodeld */, + A7896510197E66CE00855AC4 /* Supporting Files */, + ); + path = SquareCrop; + sourceTree = ""; + }; + A7896510197E66CE00855AC4 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + A7896511197E66CE00855AC4 /* Info.plist */, + A7896512197E66CE00855AC4 /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + A7896529197E66CE00855AC4 /* SquareCropTests */ = { + isa = PBXGroup; + children = ( + A789652C197E66CE00855AC4 /* SquareCropTests.m */, + A789652A197E66CE00855AC4 /* Supporting Files */, + ); + path = SquareCropTests; + sourceTree = ""; + }; + A789652A197E66CE00855AC4 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + A789652B197E66CE00855AC4 /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + A789650C197E66CE00855AC4 /* SquareCrop */ = { + isa = PBXNativeTarget; + buildConfigurationList = A7896530197E66CE00855AC4 /* Build configuration list for PBXNativeTarget "SquareCrop" */; + buildPhases = ( + A7896509197E66CE00855AC4 /* Sources */, + A789650A197E66CE00855AC4 /* Frameworks */, + A789650B197E66CE00855AC4 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SquareCrop; + productName = SquareCrop; + productReference = A789650D197E66CE00855AC4 /* SquareCrop.app */; + productType = "com.apple.product-type.application"; + }; + A7896525197E66CE00855AC4 /* SquareCropTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = A7896533197E66CE00855AC4 /* Build configuration list for PBXNativeTarget "SquareCropTests" */; + buildPhases = ( + A7896522197E66CE00855AC4 /* Sources */, + A7896523197E66CE00855AC4 /* Frameworks */, + A7896524197E66CE00855AC4 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + A7896528197E66CE00855AC4 /* PBXTargetDependency */, + A7896539197E6C5000855AC4 /* PBXTargetDependency */, + ); + name = SquareCropTests; + productName = SquareCropTests; + productReference = A7896526197E66CE00855AC4 /* SquareCropTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + A7896505197E66CE00855AC4 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0600; + ORGANIZATIONNAME = Cocoanetics; + TargetAttributes = { + A789650C197E66CE00855AC4 = { + CreatedOnToolsVersion = 6.0; + }; + A7896525197E66CE00855AC4 = { + CreatedOnToolsVersion = 6.0; + TestTargetID = A789650C197E66CE00855AC4; + }; + }; + }; + buildConfigurationList = A7896508197E66CE00855AC4 /* Build configuration list for PBXProject "SquareCrop" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = A7896504197E66CE00855AC4; + productRefGroup = A789650E197E66CE00855AC4 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + A789650C197E66CE00855AC4 /* SquareCrop */, + A7896525197E66CE00855AC4 /* SquareCropTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + A789650B197E66CE00855AC4 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A7896537197E66F600855AC4 /* Image.jpg in Resources */, + A789651F197E66CE00855AC4 /* Main.storyboard in Resources */, + A7896521197E66CE00855AC4 /* Images.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A7896524197E66CE00855AC4 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + A7896509197E66CE00855AC4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A7896516197E66CE00855AC4 /* AppDelegate.m in Sources */, + A7896519197E66CE00855AC4 /* SquareCrop.xcdatamodeld in Sources */, + A789651C197E66CE00855AC4 /* ViewController.m in Sources */, + A7896513197E66CE00855AC4 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A7896522197E66CE00855AC4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A789652D197E66CE00855AC4 /* SquareCropTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + A7896528197E66CE00855AC4 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = A789650C197E66CE00855AC4 /* SquareCrop */; + targetProxy = A7896527197E66CE00855AC4 /* PBXContainerItemProxy */; + }; + A7896539197E6C5000855AC4 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = A789650C197E66CE00855AC4 /* SquareCrop */; + targetProxy = A7896538197E6C5000855AC4 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + A789651D197E66CE00855AC4 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + A789651E197E66CE00855AC4 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + A789652E197E66CE00855AC4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + 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; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + 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 = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + A789652F197E66CE00855AC4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + 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 = YES; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + 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 = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + A7896531197E66CE00855AC4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + INFOPLIST_FILE = SquareCrop/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + A7896532197E66CE00855AC4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + INFOPLIST_FILE = SquareCrop/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + A7896534197E66CE00855AC4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SquareCrop.app/SquareCrop"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + INFOPLIST_FILE = SquareCropTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + }; + name = Debug; + }; + A7896535197E66CE00855AC4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SquareCrop.app/SquareCrop"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + INFOPLIST_FILE = SquareCropTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + A7896508197E66CE00855AC4 /* Build configuration list for PBXProject "SquareCrop" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A789652E197E66CE00855AC4 /* Debug */, + A789652F197E66CE00855AC4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + A7896530197E66CE00855AC4 /* Build configuration list for PBXNativeTarget "SquareCrop" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A7896531197E66CE00855AC4 /* Debug */, + A7896532197E66CE00855AC4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; + A7896533197E66CE00855AC4 /* Build configuration list for PBXNativeTarget "SquareCropTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A7896534197E66CE00855AC4 /* Debug */, + A7896535197E66CE00855AC4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + +/* Begin XCVersionGroup section */ + A7896517197E66CE00855AC4 /* SquareCrop.xcdatamodeld */ = { + isa = XCVersionGroup; + children = ( + A7896518197E66CE00855AC4 /* SquareCrop.xcdatamodel */, + ); + currentVersion = A7896518197E66CE00855AC4 /* SquareCrop.xcdatamodel */; + path = SquareCrop.xcdatamodeld; + sourceTree = ""; + versionGroupType = wrapper.xcdatamodel; + }; +/* End XCVersionGroup section */ + }; + rootObject = A7896505197E66CE00855AC4 /* Project object */; +} diff --git a/SquareCrop/SquareCrop/AppDelegate.h b/SquareCrop/SquareCrop/AppDelegate.h new file mode 100644 index 0000000..462444c --- /dev/null +++ b/SquareCrop/SquareCrop/AppDelegate.h @@ -0,0 +1,14 @@ +// +// AppDelegate.h +// SquareCrop +// +// Created by Oliver Drobnik on 22.07.14. +// Copyright (c) 2014 Cocoanetics. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@end + diff --git a/SquareCrop/SquareCrop/AppDelegate.m b/SquareCrop/SquareCrop/AppDelegate.m new file mode 100644 index 0000000..eb3a636 --- /dev/null +++ b/SquareCrop/SquareCrop/AppDelegate.m @@ -0,0 +1,22 @@ +// +// AppDelegate.m +// SquareCrop +// +// Created by Oliver Drobnik on 22.07.14. +// Copyright (c) 2014 Cocoanetics. 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; +} + +@end diff --git a/SquareCrop/SquareCrop/Base.lproj/Main.storyboard b/SquareCrop/SquareCrop/Base.lproj/Main.storyboard new file mode 100644 index 0000000..5da5982 --- /dev/null +++ b/SquareCrop/SquareCrop/Base.lproj/Main.storyboard @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SquareCrop/SquareCrop/Image.jpg b/SquareCrop/SquareCrop/Image.jpg new file mode 100644 index 0000000..02fb70a Binary files /dev/null and b/SquareCrop/SquareCrop/Image.jpg differ diff --git a/SquareCrop/SquareCrop/Images.xcassets/AppIcon.appiconset/Contents.json b/SquareCrop/SquareCrop/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..a396706 --- /dev/null +++ b/SquareCrop/SquareCrop/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/SquareCrop/SquareCrop/Images.xcassets/LaunchImage.launchimage/Contents.json b/SquareCrop/SquareCrop/Images.xcassets/LaunchImage.launchimage/Contents.json new file mode 100644 index 0000000..c79ebd3 --- /dev/null +++ b/SquareCrop/SquareCrop/Images.xcassets/LaunchImage.launchimage/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "orientation" : "portrait", + "idiom" : "iphone", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "subtype" : "retina4", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/SquareCrop/SquareCrop/Info.plist b/SquareCrop/SquareCrop/Info.plist new file mode 100644 index 0000000..b391409 --- /dev/null +++ b/SquareCrop/SquareCrop/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.cocoanetics.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + + diff --git a/SquareCrop/SquareCrop/ViewController.h b/SquareCrop/SquareCrop/ViewController.h new file mode 100644 index 0000000..14442c4 --- /dev/null +++ b/SquareCrop/SquareCrop/ViewController.h @@ -0,0 +1,16 @@ +// +// ViewController.h +// SquareCrop +// +// Created by Oliver Drobnik on 22.07.14. +// Copyright (c) 2014 Cocoanetics. All rights reserved. +// + +#import + +@interface ViewController : UIViewController + +@property (weak, nonatomic) IBOutlet UIImageView *imageView; + +@end + diff --git a/SquareCrop/SquareCrop/ViewController.m b/SquareCrop/SquareCrop/ViewController.m new file mode 100644 index 0000000..c9909b8 --- /dev/null +++ b/SquareCrop/SquareCrop/ViewController.m @@ -0,0 +1,79 @@ +// +// ViewController.m +// SquareCrop +// +// Created by Oliver Drobnik on 22.07.14. +// Copyright (c) 2014 Cocoanetics. All rights reserved. +// + +#import "ViewController.h" + +@interface ViewController () + +@end + + +UIImage *squareCropImageToSideLength(UIImage *sourceImage, + CGFloat sideLength) +{ + // input size comes from image + CGSize inputSize = sourceImage.size; + + // round up side length to avoid fractional output size + sideLength = ceilf(sideLength); + + // output size has sideLength for both dimensions + CGSize outputSize = CGSizeMake(sideLength, sideLength); + + // calculate scale so that smaller dimension fits sideLength + CGFloat scale = MAX(sideLength / inputSize.width, + sideLength / inputSize.height); + + // scaling the image with this scale results in this output size + CGSize scaledInputSize = CGSizeMake(inputSize.width * scale, + inputSize.height * scale); + + // determine point in center of "canvas" + CGPoint center = CGPointMake(outputSize.width/2.0, + outputSize.height/2.0); + + // calculate drawing rect relative to output Size + CGRect outputRect = CGRectMake(center.x - scaledInputSize.width/2.0, + center.y - scaledInputSize.height/2.0, + scaledInputSize.width, + scaledInputSize.height); + + // begin a new bitmap context, scale 0 takes display scale + UIGraphicsBeginImageContextWithOptions(outputSize, YES, 0); + + // optional: set the interpolation quality. + // For this you need to grab the underlying CGContext + CGContextRef ctx = UIGraphicsGetCurrentContext(); + CGContextSetInterpolationQuality(ctx, kCGInterpolationHigh); + + // draw the source image into the calculated rect + [sourceImage drawInRect:outputRect]; + + // create new image from bitmap context + UIImage *outImage = UIGraphicsGetImageFromCurrentImageContext(); + + // clean up + UIGraphicsEndImageContext(); + + // pass back new image + return outImage; +} + + +@implementation ViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view, typically from a nib. + + UIImage *image = [UIImage imageNamed:@"Image.jpg"]; + UIImage *scaled = squareCropImageToSideLength(image, 300); + self.imageView.image = scaled; +} + +@end diff --git a/SquareCrop/SquareCrop/main.m b/SquareCrop/SquareCrop/main.m new file mode 100644 index 0000000..6026ad4 --- /dev/null +++ b/SquareCrop/SquareCrop/main.m @@ -0,0 +1,16 @@ +// +// main.m +// SquareCrop +// +// Created by Oliver Drobnik on 22.07.14. +// Copyright (c) 2014 Cocoanetics. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +}