diff --git a/JTAlertView Example/.gitignore b/JTAlertView Example/.gitignore new file mode 100644 index 0000000..73dcde5 --- /dev/null +++ b/JTAlertView Example/.gitignore @@ -0,0 +1,20 @@ +# Xcode +.DS_Store +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +*.xcworkspace +!default.xcworkspace +xcuserdata +profile +*.moved-aside +DerivedData +.idea/ +# Pods - for those of you who use CocoaPods +Pods diff --git a/JTAlertView Example/JTAlertView Example.xcodeproj/project.pbxproj b/JTAlertView Example/JTAlertView Example.xcodeproj/project.pbxproj new file mode 100644 index 0000000..a7268ff --- /dev/null +++ b/JTAlertView Example/JTAlertView Example.xcodeproj/project.pbxproj @@ -0,0 +1,448 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 3BD1B1AC1B2CBE7600621F68 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3BD1B1AB1B2CBE7600621F68 /* main.m */; }; + 3BD1B1AF1B2CBE7600621F68 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 3BD1B1AE1B2CBE7600621F68 /* AppDelegate.m */; }; + 3BD1B1B21B2CBE7600621F68 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3BD1B1B11B2CBE7600621F68 /* ViewController.m */; }; + 3BD1B1B51B2CBE7600621F68 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3BD1B1B31B2CBE7600621F68 /* Main.storyboard */; }; + 3BD1B1B71B2CBE7600621F68 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3BD1B1B61B2CBE7600621F68 /* Images.xcassets */; }; + 3BD1B1BA1B2CBE7600621F68 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3BD1B1B81B2CBE7600621F68 /* LaunchScreen.xib */; }; + 3BD1B1C61B2CBE7600621F68 /* JTAlertView_ExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3BD1B1C51B2CBE7600621F68 /* JTAlertView_ExampleTests.m */; }; + 3BDCD9A51B30393E006944F9 /* JTAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3BDCD9A41B30393E006944F9 /* JTAlertView.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 3BD1B1C01B2CBE7600621F68 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 3BD1B19E1B2CBE7600621F68 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 3BD1B1A51B2CBE7600621F68; + remoteInfo = "JTAlertView Example"; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 3BD1B1A61B2CBE7600621F68 /* JTAlertView Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "JTAlertView Example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 3BD1B1AA1B2CBE7600621F68 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 3BD1B1AB1B2CBE7600621F68 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 3BD1B1AD1B2CBE7600621F68 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 3BD1B1AE1B2CBE7600621F68 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 3BD1B1B01B2CBE7600621F68 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 3BD1B1B11B2CBE7600621F68 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 3BD1B1B41B2CBE7600621F68 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 3BD1B1B61B2CBE7600621F68 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + 3BD1B1B91B2CBE7600621F68 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; + 3BD1B1BF1B2CBE7600621F68 /* JTAlertView ExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "JTAlertView ExampleTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + 3BD1B1C41B2CBE7600621F68 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 3BD1B1C51B2CBE7600621F68 /* JTAlertView_ExampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JTAlertView_ExampleTests.m; sourceTree = ""; }; + 3BDCD9A31B30393E006944F9 /* JTAlertView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JTAlertView.h; sourceTree = ""; }; + 3BDCD9A41B30393E006944F9 /* JTAlertView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JTAlertView.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 3BD1B1A31B2CBE7600621F68 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 3BD1B1BC1B2CBE7600621F68 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 3BD1B19D1B2CBE7600621F68 = { + isa = PBXGroup; + children = ( + 3BDCD9A21B30393E006944F9 /* JTAlertView */, + 3BD1B1A81B2CBE7600621F68 /* JTAlertView Example */, + 3BD1B1C21B2CBE7600621F68 /* JTAlertView ExampleTests */, + 3BD1B1A71B2CBE7600621F68 /* Products */, + ); + sourceTree = ""; + }; + 3BD1B1A71B2CBE7600621F68 /* Products */ = { + isa = PBXGroup; + children = ( + 3BD1B1A61B2CBE7600621F68 /* JTAlertView Example.app */, + 3BD1B1BF1B2CBE7600621F68 /* JTAlertView ExampleTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 3BD1B1A81B2CBE7600621F68 /* JTAlertView Example */ = { + isa = PBXGroup; + children = ( + 3BD1B1AD1B2CBE7600621F68 /* AppDelegate.h */, + 3BD1B1AE1B2CBE7600621F68 /* AppDelegate.m */, + 3BD1B1B01B2CBE7600621F68 /* ViewController.h */, + 3BD1B1B11B2CBE7600621F68 /* ViewController.m */, + 3BD1B1B31B2CBE7600621F68 /* Main.storyboard */, + 3BD1B1B61B2CBE7600621F68 /* Images.xcassets */, + 3BD1B1B81B2CBE7600621F68 /* LaunchScreen.xib */, + 3BD1B1A91B2CBE7600621F68 /* Supporting Files */, + ); + path = "JTAlertView Example"; + sourceTree = ""; + }; + 3BD1B1A91B2CBE7600621F68 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 3BD1B1AA1B2CBE7600621F68 /* Info.plist */, + 3BD1B1AB1B2CBE7600621F68 /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 3BD1B1C21B2CBE7600621F68 /* JTAlertView ExampleTests */ = { + isa = PBXGroup; + children = ( + 3BD1B1C51B2CBE7600621F68 /* JTAlertView_ExampleTests.m */, + 3BD1B1C31B2CBE7600621F68 /* Supporting Files */, + ); + path = "JTAlertView ExampleTests"; + sourceTree = ""; + }; + 3BD1B1C31B2CBE7600621F68 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 3BD1B1C41B2CBE7600621F68 /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 3BDCD9A21B30393E006944F9 /* JTAlertView */ = { + isa = PBXGroup; + children = ( + 3BDCD9A31B30393E006944F9 /* JTAlertView.h */, + 3BDCD9A41B30393E006944F9 /* JTAlertView.m */, + ); + name = JTAlertView; + path = ../JTAlertView; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 3BD1B1A51B2CBE7600621F68 /* JTAlertView Example */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3BD1B1C91B2CBE7600621F68 /* Build configuration list for PBXNativeTarget "JTAlertView Example" */; + buildPhases = ( + 3BD1B1A21B2CBE7600621F68 /* Sources */, + 3BD1B1A31B2CBE7600621F68 /* Frameworks */, + 3BD1B1A41B2CBE7600621F68 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "JTAlertView Example"; + productName = "JTAlertView Example"; + productReference = 3BD1B1A61B2CBE7600621F68 /* JTAlertView Example.app */; + productType = "com.apple.product-type.application"; + }; + 3BD1B1BE1B2CBE7600621F68 /* JTAlertView ExampleTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3BD1B1CC1B2CBE7600621F68 /* Build configuration list for PBXNativeTarget "JTAlertView ExampleTests" */; + buildPhases = ( + 3BD1B1BB1B2CBE7600621F68 /* Sources */, + 3BD1B1BC1B2CBE7600621F68 /* Frameworks */, + 3BD1B1BD1B2CBE7600621F68 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 3BD1B1C11B2CBE7600621F68 /* PBXTargetDependency */, + ); + name = "JTAlertView ExampleTests"; + productName = "JTAlertView ExampleTests"; + productReference = 3BD1B1BF1B2CBE7600621F68 /* JTAlertView ExampleTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 3BD1B19E1B2CBE7600621F68 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0630; + ORGANIZATIONNAME = "Jakub Truhlar"; + TargetAttributes = { + 3BD1B1A51B2CBE7600621F68 = { + CreatedOnToolsVersion = 6.3.2; + }; + 3BD1B1BE1B2CBE7600621F68 = { + CreatedOnToolsVersion = 6.3.2; + TestTargetID = 3BD1B1A51B2CBE7600621F68; + }; + }; + }; + buildConfigurationList = 3BD1B1A11B2CBE7600621F68 /* Build configuration list for PBXProject "JTAlertView Example" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 3BD1B19D1B2CBE7600621F68; + productRefGroup = 3BD1B1A71B2CBE7600621F68 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 3BD1B1A51B2CBE7600621F68 /* JTAlertView Example */, + 3BD1B1BE1B2CBE7600621F68 /* JTAlertView ExampleTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 3BD1B1A41B2CBE7600621F68 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3BD1B1B51B2CBE7600621F68 /* Main.storyboard in Resources */, + 3BD1B1BA1B2CBE7600621F68 /* LaunchScreen.xib in Resources */, + 3BD1B1B71B2CBE7600621F68 /* Images.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 3BD1B1BD1B2CBE7600621F68 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 3BD1B1A21B2CBE7600621F68 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3BD1B1B21B2CBE7600621F68 /* ViewController.m in Sources */, + 3BDCD9A51B30393E006944F9 /* JTAlertView.m in Sources */, + 3BD1B1AF1B2CBE7600621F68 /* AppDelegate.m in Sources */, + 3BD1B1AC1B2CBE7600621F68 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 3BD1B1BB1B2CBE7600621F68 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3BD1B1C61B2CBE7600621F68 /* JTAlertView_ExampleTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 3BD1B1C11B2CBE7600621F68 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 3BD1B1A51B2CBE7600621F68 /* JTAlertView Example */; + targetProxy = 3BD1B1C01B2CBE7600621F68 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 3BD1B1B31B2CBE7600621F68 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 3BD1B1B41B2CBE7600621F68 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 3BD1B1B81B2CBE7600621F68 /* LaunchScreen.xib */ = { + isa = PBXVariantGroup; + children = ( + 3BD1B1B91B2CBE7600621F68 /* Base */, + ); + name = LaunchScreen.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 3BD1B1C71B2CBE7600621F68 /* 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; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = 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_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.3; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 3BD1B1C81B2CBE7600621F68 /* 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 = 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 = 8.3; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 3BD1B1CA1B2CBE7600621F68 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = "JTAlertView Example/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 3BD1B1CB1B2CBE7600621F68 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = "JTAlertView Example/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + 3BD1B1CD1B2CBE7600621F68 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + INFOPLIST_FILE = "JTAlertView ExampleTests/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/JTAlertView Example.app/JTAlertView Example"; + }; + name = Debug; + }; + 3BD1B1CE1B2CBE7600621F68 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + INFOPLIST_FILE = "JTAlertView ExampleTests/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/JTAlertView Example.app/JTAlertView Example"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 3BD1B1A11B2CBE7600621F68 /* Build configuration list for PBXProject "JTAlertView Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3BD1B1C71B2CBE7600621F68 /* Debug */, + 3BD1B1C81B2CBE7600621F68 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3BD1B1C91B2CBE7600621F68 /* Build configuration list for PBXNativeTarget "JTAlertView Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3BD1B1CA1B2CBE7600621F68 /* Debug */, + 3BD1B1CB1B2CBE7600621F68 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3BD1B1CC1B2CBE7600621F68 /* Build configuration list for PBXNativeTarget "JTAlertView ExampleTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3BD1B1CD1B2CBE7600621F68 /* Debug */, + 3BD1B1CE1B2CBE7600621F68 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 3BD1B19E1B2CBE7600621F68 /* Project object */; +} diff --git a/JTAlertView Example/JTAlertView Example/AppDelegate.h b/JTAlertView Example/JTAlertView Example/AppDelegate.h new file mode 100644 index 0000000..061bf1f --- /dev/null +++ b/JTAlertView Example/JTAlertView Example/AppDelegate.h @@ -0,0 +1,17 @@ +// +// AppDelegate.h +// JTAlertView Example +// +// Created by Jakub Truhlar on 13.06.15. +// Copyright (c) 2015 Jakub Truhlar. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/JTAlertView Example/JTAlertView Example/AppDelegate.m b/JTAlertView Example/JTAlertView Example/AppDelegate.m new file mode 100644 index 0000000..bc1c1bc --- /dev/null +++ b/JTAlertView Example/JTAlertView Example/AppDelegate.m @@ -0,0 +1,45 @@ +// +// AppDelegate.m +// JTAlertView Example +// +// Created by Jakub Truhlar on 13.06.15. +// Copyright (c) 2015 Jakub Truhlar. 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 throttle down OpenGL ES frame rates. 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 inactive 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/JTAlertView Example/JTAlertView Example/Base.lproj/LaunchScreen.xib b/JTAlertView Example/JTAlertView Example/Base.lproj/LaunchScreen.xib new file mode 100644 index 0000000..46caa4f --- /dev/null +++ b/JTAlertView Example/JTAlertView Example/Base.lproj/LaunchScreen.xib @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/JTAlertView Example/JTAlertView Example/Base.lproj/Main.storyboard b/JTAlertView Example/JTAlertView Example/Base.lproj/Main.storyboard new file mode 100644 index 0000000..ce7c5ea --- /dev/null +++ b/JTAlertView Example/JTAlertView Example/Base.lproj/Main.storyboard @@ -0,0 +1,276 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/JTAlertView Example/JTAlertView Example/Images.xcassets/AppIcon.appiconset/Contents.json b/JTAlertView Example/JTAlertView Example/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..118c98f --- /dev/null +++ b/JTAlertView Example/JTAlertView Example/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,38 @@ +{ + "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" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/JTAlertView Example/JTAlertView Example/Images.xcassets/city.imageset/Contents.json b/JTAlertView Example/JTAlertView Example/Images.xcassets/city.imageset/Contents.json new file mode 100644 index 0000000..aec64d5 --- /dev/null +++ b/JTAlertView Example/JTAlertView Example/Images.xcassets/city.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "city@2x.png" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/JTAlertView Example/JTAlertView Example/Images.xcassets/city.imageset/city@2x.png b/JTAlertView Example/JTAlertView Example/Images.xcassets/city.imageset/city@2x.png new file mode 100644 index 0000000..e2b6bbf Binary files /dev/null and b/JTAlertView Example/JTAlertView Example/Images.xcassets/city.imageset/city@2x.png differ diff --git a/JTAlertView Example/JTAlertView Example/Info.plist b/JTAlertView Example/JTAlertView Example/Info.plist new file mode 100644 index 0000000..d532dfe --- /dev/null +++ b/JTAlertView Example/JTAlertView Example/Info.plist @@ -0,0 +1,46 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + com.jakubtruhlar.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UIStatusBarHidden + + UIStatusBarStyle + UIStatusBarStyleLightContent + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + + diff --git a/JTAlertView Example/JTAlertView Example/ViewController.h b/JTAlertView Example/JTAlertView Example/ViewController.h new file mode 100644 index 0000000..7be1e34 --- /dev/null +++ b/JTAlertView Example/JTAlertView Example/ViewController.h @@ -0,0 +1,31 @@ +// +// ViewController.h +// JTAlertView Example +// +// Created by Jakub Truhlar on 13.06.15. +// Copyright (c) 2015 Jakub Truhlar. All rights reserved. +// + +#import + +@interface ViewController : UIViewController + +@property (weak, nonatomic) IBOutlet UISegmentedControl *segmentControl; +@property (weak, nonatomic) IBOutlet UISwitch *destructiveSwitch; +@property (weak, nonatomic) IBOutlet UISwitch *animatedSwitch; +@property (weak, nonatomic) IBOutlet UISwitch *popSwitch; +@property (weak, nonatomic) IBOutlet UISwitch *parallaxSwitch; +@property (weak, nonatomic) IBOutlet UISwitch *fontSwitch; + +- (IBAction)showPressed:(id)sender; + +- (IBAction)segmentSwitch:(id)sender; + +- (IBAction)animatedSwitch:(id)sender; +- (IBAction)destructiveSwitch:(id)sender; +- (IBAction)popSwitch:(id)sender; +- (IBAction)parallaxSwitch:(id)sender; +- (IBAction)fontSwitch:(id)sender; + +@end + diff --git a/JTAlertView Example/JTAlertView Example/ViewController.m b/JTAlertView Example/JTAlertView Example/ViewController.m new file mode 100644 index 0000000..0917dc6 --- /dev/null +++ b/JTAlertView Example/JTAlertView Example/ViewController.m @@ -0,0 +1,155 @@ +// +// ViewController.m +// JTAlertView Example +// +// Created by Jakub Truhlar on 13.06.15. +// Copyright (c) 2015 Jakub Truhlar. All rights reserved. +// + +#import "ViewController.h" +#import "JTAlertView.h" + +@interface ViewController () + +@property (nonatomic, strong) JTAlertView *alertView; +@property (nonatomic, assign) bool animated; +@property (nonatomic, assign) bool destructive; +@property (nonatomic, strong) UIFont *customFont; +@property (nonatomic, assign) bool pop; +@property (nonatomic, assign) bool parallax; +@property (nonatomic, assign) NSInteger numberOfButtons; + +@end + +@implementation ViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + // Example settings + _numberOfButtons = 2; + _animated = true; + _destructive = false; + _pop = true; + _parallax = true; + _customFont = nil; + + _segmentControl.selectedSegmentIndex = _numberOfButtons; + _animatedSwitch.on = _animated; + _destructiveSwitch.on = _destructive; + _popSwitch.on = _pop; + _parallaxSwitch.on = _parallax; + _fontSwitch.on = _customFont ? true : false; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; +} + +- (IBAction)showPressed:(id)sender { + self.alertView = [[JTAlertView alloc] initWithTitle:[@"Hello, I'm a brand new alertView" uppercaseString] andImage:[UIImage imageNamed:@"city"]]; + self.alertView.size = CGSizeMake(280, 230); + self.alertView.popAnimation = _pop; + self.alertView.parallaxEffect = _parallax; + + __weak typeof(self)weakSelf = self; + + switch (_numberOfButtons) { + case 0: + [self.alertView hideWithDelay:1.5 animated:weakSelf.animated]; + [self performSelector:@selector(fadeExampleSettings) withObject:nil afterDelay:1.5]; + break; + case 1: + if (_destructive) { + [self.alertView addButtonWithTitle:@"DELETE" font:_customFont style:JTAlertViewStyleDestructive forControlEvents:UIControlEventTouchUpInside action:^(JTAlertView *alertView) { + NSLog(@"JTAlertView: DELETE pressed"); + [alertView hideWithCompletion:nil animated:weakSelf.animated]; + [weakSelf fadeExampleSettings]; + }]; + } else { + [self.alertView addButtonWithTitle:@"OK" font:_customFont style:JTAlertViewStyleDefault forControlEvents:UIControlEventTouchUpInside action:^(JTAlertView *alertView) { + NSLog(@"JTAlertView: OK pressed"); + [alertView hideWithCompletion:nil animated:weakSelf.animated]; + [weakSelf fadeExampleSettings]; + }]; + } + break; + case 2: + if (_destructive) { + [self.alertView addButtonWithTitle:@"CANCEL" font:_customFont style:JTAlertViewStyleDefault forControlEvents:UIControlEventTouchUpInside action:^(JTAlertView *alertView) { + NSLog(@"JTAlertView: CANCEL pressed"); + [alertView hideWithCompletion:nil animated:weakSelf.animated]; + [weakSelf fadeExampleSettings]; + }]; + [self.alertView addButtonWithTitle:@"DELETE" font:_customFont style:JTAlertViewStyleDestructive forControlEvents:UIControlEventTouchUpInside action:^(JTAlertView *alertView) { + NSLog(@"JTAlertView: DELETE pressed"); + [alertView hideWithCompletion:nil animated:weakSelf.animated]; + [weakSelf fadeExampleSettings]; + }]; + } else { + [self.alertView addButtonWithTitle:@"OK" font:_customFont style:JTAlertViewStyleDefault forControlEvents:UIControlEventTouchUpInside action:^(JTAlertView *alertView) { + NSLog(@"JTAlertView: OK pressed"); + [alertView hideWithCompletion:nil animated:weakSelf.animated]; + [weakSelf fadeExampleSettings]; + }]; + [self.alertView addButtonWithTitle:@"CANCEL" font:_customFont style:JTAlertViewStyleCancel forControlEvents:UIControlEventTouchUpInside action:^(JTAlertView *alertView) { + NSLog(@"JTAlertView: CANCEL pressed"); + [alertView hideWithCompletion:nil animated:weakSelf.animated]; + [weakSelf fadeExampleSettings]; + }]; + } + break; + default: + break; + } + + [self.alertView showInSuperview:[[UIApplication sharedApplication] keyWindow] withCompletion:nil animated:_animated]; + + [self fadeExampleSettings]; +} + +#pragma mark - Example Controls, Handles etc. + +- (void)fadeExampleSettings { + [UIView animateWithDuration:0.1 animations:^{ + for (UIView *s in self.view.subviews) { + s.alpha = s.alpha ? 0.0 : 1.0; + } + } completion:nil]; +} + +- (IBAction)segmentSwitch:(id)sender { + UISegmentedControl *segmentedControl = (UISegmentedControl *)sender; + _numberOfButtons = segmentedControl.selectedSegmentIndex; +} + +- (IBAction)animatedSwitch:(id)sender { + UISwitch *animatedSwitch = (UISwitch *)sender; + _animated = animatedSwitch.isOn; +} + +- (IBAction)destructiveSwitch:(id)sender { + UISwitch *destructiveSwitch = (UISwitch *)sender; + _destructive = destructiveSwitch.isOn; +} + +- (IBAction)popSwitch:(id)sender { + UISwitch *popSwitch = (UISwitch *)sender; + _pop = popSwitch.isOn; +} + +- (IBAction)parallaxSwitch:(id)sender { + UISwitch *parallaxSwitch = (UISwitch *)sender; + _parallax = parallaxSwitch.isOn; +} + +- (IBAction)fontSwitch:(id)sender { + UISwitch *fontSwitch = (UISwitch *)sender; + if (fontSwitch.isOn) { + _customFont = [UIFont fontWithName:@"Menlo" size:21.0]; + } else { + _customFont = nil; + } +} + +@end diff --git a/JTAlertView Example/JTAlertView Example/main.m b/JTAlertView Example/JTAlertView Example/main.m new file mode 100644 index 0000000..4960297 --- /dev/null +++ b/JTAlertView Example/JTAlertView Example/main.m @@ -0,0 +1,16 @@ +// +// main.m +// JTAlertView Example +// +// Created by Jakub Truhlar on 13.06.15. +// Copyright (c) 2015 Jakub Truhlar. 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/JTAlertView Example/JTAlertView ExampleTests/Info.plist b/JTAlertView Example/JTAlertView ExampleTests/Info.plist new file mode 100644 index 0000000..f082bc0 --- /dev/null +++ b/JTAlertView Example/JTAlertView ExampleTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + com.jakubtruhlar.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/JTAlertView Example/JTAlertView ExampleTests/JTAlertView_ExampleTests.m b/JTAlertView Example/JTAlertView ExampleTests/JTAlertView_ExampleTests.m new file mode 100644 index 0000000..90681fd --- /dev/null +++ b/JTAlertView Example/JTAlertView ExampleTests/JTAlertView_ExampleTests.m @@ -0,0 +1,40 @@ +// +// JTAlertView_ExampleTests.m +// JTAlertView ExampleTests +// +// Created by Jakub Truhlar on 13.06.15. +// Copyright (c) 2015 Jakub Truhlar. All rights reserved. +// + +#import +#import + +@interface JTAlertView_ExampleTests : XCTestCase + +@end + +@implementation JTAlertView_ExampleTests + +- (void)setUp { + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + // This is an example of a functional test case. + XCTAssert(YES, @"Pass"); +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end diff --git a/JTAlertView.podspec b/JTAlertView.podspec new file mode 100644 index 0000000..4b416a6 --- /dev/null +++ b/JTAlertView.podspec @@ -0,0 +1,21 @@ +Pod::Spec.new do |s| + s.name = "JTAlertView" + s.version = "1.0.0" + s.summary = "JTAlertView is the new **wonderful dialog/HUD/alert** kind of View." + + s.description = <<-DESC + **JTAlertView** is the new **wonderful dialog/HUD/alert** kind of View. It was also designed to cover user’s needs during **customization**. Created with **delightful combination** of image, parallax and pop effects, **JTAlertView** improves your user experience. + DESC + + s.homepage = "https://github.com/kubatru/JTAlertView" + s.screenshots = "https://github.com/kubatru/JTAlertView/blob/master/Screens/alertView.png" + + s.license = { :type => "MIT", :file => "LICENSE.md" } + s.author = "Jakub Truhlar" + s.social_media_url = "http://kubatruhlar.cz" + s.platform = :ios, "7.0" + s.source = { :git => "https://github.com/kubatru/JTAlertView.git", :tag => "1.0.0" } + s.source_files = "JTAlertView/*" + s.framework = "UIKit" + s.requires_arc = true +end diff --git a/JTAlertView/JTAlertView.h b/JTAlertView/JTAlertView.h new file mode 100644 index 0000000..77d4edf --- /dev/null +++ b/JTAlertView/JTAlertView.h @@ -0,0 +1,68 @@ +// +// JTAlertView.h +// +// Created by Jakub Truhlar on 07.06.15. +// Copyright (c) 2015 Jakub Truhlar. All rights reserved. +// + +#import + +@interface JTAlertView : UIView + +/** In Cancel and Destructive case JTAlertView will try to use bold version of your font (Must be in format FontName-Bold) */ +typedef NS_ENUM(NSInteger, JTAlertViewStyle) { + JTAlertViewStyleDefault = 0, + JTAlertViewStyleCancel, + JTAlertViewStyleDestructive +}; + +// Public properties +/** Size of the alertView. Default is 240.0, 290.0. */ +@property (nonatomic, assign) CGSize size; + +/** Pop animation of the alertView when shows and pressed (Disable animated show will also disable pop show animation). Default is YES. */ +@property (nonatomic, assign) bool popAnimation; + +/** Beautiful parallax effect of image within alertView. Default is YES. */ +@property (nonatomic, assign) bool parallaxEffect; + +/** Image overlay. Default overlay is gray with half alpha. */ +@property (nonatomic, strong) UIColor *overlayColor; + +/** Font applied on title and alertView buttons. AlertView buttons will ignore this font's size but not the style (In case you want to setup custom font for your buttons, use font parameter in method instead). Default is Helvetica Neue Medium with 21.0 size. */ +@property (nonatomic, strong) UIFont *font; + +/** Color of the alertView's title. Default is white. */ +@property (nonatomic, strong) UIColor *titleColor; + +/** Shadow underneath the title. Default is YES. */ +@property (nonatomic, assign) bool titleShadow; + +// Initializers ++ (instancetype)alertWithTitle:(NSString *)titleText andImage:(UIImage *)image; +- (instancetype)initWithTitle:(NSString *)titleText andImage:(UIImage *)image; + +// Buttons +- (void)addButtonWithTitle:(NSString *)titleText action:(void (^)(JTAlertView *alertView))action; +- (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style action:(void (^)(JTAlertView *alertView))action; +- (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action; +- (void)addButtonWithTitle:(NSString *)titleText font:(UIFont *)font style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action; + +// Displaying +- (void)show; +- (void)showInSuperview:(UIView *)superView withCompletion:(void (^)())completion animated:(bool)animated; +- (void)hide; +- (void)hideWithCompletion:(void (^)())completion animated:(bool)animated; +- (void)hideWithDelay:(NSTimeInterval)delay animated:(bool)animated; + +@end + +// UIButton Subclass +@interface UIBlockButton : UIButton + +typedef void (^ActionBlock)(JTAlertView *alertView); +@property (nonatomic, strong) ActionBlock actionBlock; + +- (void)handleControlEvent:(UIControlEvents)event withBlock:(ActionBlock)action; + +@end diff --git a/JTAlertView/JTAlertView.m b/JTAlertView/JTAlertView.m new file mode 100644 index 0000000..713b2be --- /dev/null +++ b/JTAlertView/JTAlertView.m @@ -0,0 +1,413 @@ +// +// JTAlertView.m +// +// Created by Jakub Truhlar on 07.06.15. +// Copyright (c) 2015 Jakub Truhlar. All rights reserved. +// + +#import "JTAlertView.h" + +const static CGFloat kAlertWidth = 240.0; +const static CGFloat kAlertHeight = 290.0; +const static CGFloat kButtonHeight = 50.0; +const static CGFloat kCornerRadius = 5.0; +const static CGFloat kTitlePadding = 16.0; + +const static CGFloat kParallaxEffectDivergence = 10.0; +const static CGFloat kAnimatingDuration = 0.2; + +const static CGFloat kShadowOffsetValue = 0.5; +const static CGFloat kBtnHighlightValue = 0.9; +const static CGFloat kSeparatorColorValue = 0.97; +const static CGFloat kBtnFontSize = 19.0; +const static CGFloat kTitleFontSize = 21.0; + +@interface JTAlertView() + +@property (nonatomic, strong) NSString *alertTitle; +@property (nonatomic, strong) UIImage *alertImage; +@property (nonatomic, strong) NSMutableArray *btns; +@property (nonatomic, strong) UIImageView *imgView; +@property (nonatomic, strong) UILabel *titleLabel; +@property (nonatomic, strong) UITapGestureRecognizer *gestureRecognizer; + +@end + +@implementation JTAlertView + +#pragma mark - Initializers +- (instancetype)init { + return [self initWithTitle:nil andImage:nil]; +} + +- (instancetype)initWithFrame:(CGRect)frame { + return [self initWithTitle:nil andImage:nil]; +} + +- (instancetype)initWithTitle:(NSString *)titleText andImage:(UIImage *)image { + _size = CGSizeMake(kAlertWidth, kAlertHeight); + self = [super initWithFrame:[self alertFrameWithinScreen]]; + + // Default setup of public properties + [self defaultSetup]; + + // Start with hidden view + [self noAlpha]; + + self.alertTitle = titleText; + self.alertImage = image; + + // Inits + self.btns = [NSMutableArray new]; + + // Notifications + [self createObservers]; + + return self; +} + ++ (instancetype)alertWithTitle:(NSString *)titleText andImage:(UIImage *)image { + return [(JTAlertView *)[self alloc] initWithTitle:titleText andImage:image]; +} + +#pragma mark - Buttons handle +- (void)addButtonWithTitle:(NSString *)titleText action:(void (^)(JTAlertView *alertView))action { + + [self addButtonWithTitle:titleText style:JTAlertViewStyleDefault action:action]; +} + +- (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style action:(void (^)(JTAlertView *alertView))action { + + [self addButtonWithTitle:titleText style:style forControlEvents:UIControlEventTouchUpInside action:action]; +} + +- (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action { + [self addButtonWithTitle:titleText font:nil style:style forControlEvents:controlEvents action:action]; +} + +- (void)addButtonWithTitle:(NSString *)titleText font:(UIFont *)font style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action { + + UIBlockButton *btn = [UIBlockButton buttonWithType:UIButtonTypeSystem]; + [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; + [btn setBackgroundColor:[UIColor whiteColor]]; + [btn setTitle:titleText forState:UIControlStateNormal]; + [btn handleControlEvent:controlEvents withBlock:action]; + + if (!font) { + switch (style) { + case JTAlertViewStyleDefault: + btn.titleLabel.font = [_font fontWithSize:kBtnFontSize]; + break; + case JTAlertViewStyleCancel: + btn.titleLabel.font = [self boldForFont:_font withSize:kBtnFontSize] ? [self boldForFont:_font withSize:kBtnFontSize] : [_font fontWithSize:kBtnFontSize]; + break; + case JTAlertViewStyleDestructive: + btn.titleLabel.font = [self boldForFont:_font withSize:kBtnFontSize] ? [self boldForFont:_font withSize:kBtnFontSize] : [_font fontWithSize:kBtnFontSize]; + [btn setTitleColor:[UIColor colorWithRed:0.906 green:0.298 blue:0.235 alpha:1] forState:UIControlStateNormal]; + break; + default: + break; + } + } else { + switch (style) { + case JTAlertViewStyleDefault: + btn.titleLabel.font = font; + break; + case JTAlertViewStyleCancel: + btn.titleLabel.font = [self boldForFont:font withSize:font.pointSize] ? [self boldForFont:font withSize:font.pointSize] : font; + break; + case JTAlertViewStyleDestructive: + btn.titleLabel.font = [self boldForFont:font withSize:font.pointSize] ? [self boldForFont:font withSize:font.pointSize] : font; + [btn setTitleColor:[UIColor colorWithRed:0.906 green:0.298 blue:0.235 alpha:1] forState:UIControlStateNormal]; + break; + default: + break; + } + } + + [self.btns addObject:btn]; + + [self layoutBtns]; +} + +- (void)layoutBtns { + for (int i = 0; i < self.btns.count; i++) { + // Remove all buttons + UIButton *b = [self.btns objectAtIndex:i]; + [b removeFromSuperview]; + + // Remove all separators + [[self viewWithTag:1] removeFromSuperview]; + [[self viewWithTag:2] removeFromSuperview]; + } + + // Setup frame + CGFloat btnWidth = self.frame.size.width / self.btns.count; + for (int i = 0; i < self.btns.count; i++) { + UIButton *b = [self.btns objectAtIndex:i]; + b.frame = CGRectMake(btnWidth * i, _size.height - kButtonHeight, btnWidth, kButtonHeight); + [b setBackgroundImage:[self jt_imageWithColor:[UIColor colorWithWhite:kBtnHighlightValue alpha:1.0] size:b.frame.size] forState:UIControlStateHighlighted]; + [self insertSubview:b atIndex:1]; + + if (i < self.btns.count - 1) { + // Add a vertical separator + [self addSeparatorInView:self withTag:1 andFrame:CGRectMake(b.frame.size.width * (i + 1), b.frame.origin.y, 1.0, b.frame.size.height)]; + } else if (i == self.btns.count - 1) { + // In the last loop - add a horizontal separator + [self addSeparatorInView:self withTag:2 andFrame:CGRectMake(0, b.frame.origin.y, self.frame.size.width, 1.0)]; + } + } +} + +- (void)addSeparatorInView:(UIView *)superview withTag:(NSInteger)tag andFrame:(CGRect)frame { + UIView *separator = [[UIView alloc] initWithFrame:frame]; + separator.backgroundColor = [UIColor colorWithWhite:kSeparatorColorValue alpha:1.0]; + separator.tag = tag; + [superview insertSubview:separator atIndex:2]; +} + +#pragma mark - Appearance +- (void)applyAppearanceConsideringButtons:(bool)consideringBtns { + // Self + self.layer.cornerRadius = kCornerRadius; + self.layer.masksToBounds = true; + self.layer.backgroundColor = [UIColor whiteColor].CGColor; + + // ImageView + CGFloat imgHeight; + imgHeight = consideringBtns ? self.frame.size.height - kButtonHeight : self.frame.size.height; + // Parallax effect + CGFloat parallaxDivergence; + if (_parallaxEffect) { + //[self applyMotionEffects:self]; + parallaxDivergence = kParallaxEffectDivergence; + } else { + parallaxDivergence = 0; + } + _imgView = [[UIImageView alloc] initWithFrame:CGRectMake(-parallaxDivergence, -parallaxDivergence, self.frame.size.width + parallaxDivergence * 2, imgHeight + parallaxDivergence * 2)]; + _imgView.contentMode = UIViewContentModeScaleAspectFill; + _imgView.userInteractionEnabled = true; + if (_parallaxEffect) { + [self applyMotionEffects:_imgView]; + } + _imgView.image = _alertImage; + // Create overlay + UIView *overlay = [[UIView alloc] initWithFrame:_imgView.bounds]; + overlay.userInteractionEnabled = true; + overlay.backgroundColor = _overlayColor; + [_imgView addSubview:overlay]; + [self insertSubview:_imgView atIndex:0]; + + // Label + _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(kTitlePadding, kTitlePadding, self.frame.size.width - kTitlePadding * 2, imgHeight - kTitlePadding * 2)]; + _titleLabel.numberOfLines = 0; + _titleLabel.font = _font; + _titleLabel.textColor = _titleColor; + _titleLabel.text = _alertTitle; + _titleLabel.textAlignment = NSTextAlignmentCenter; + if (_titleShadow) { + _titleLabel.layer.shadowOpacity = 1.0; + _titleLabel.layer.shadowColor = [[UIColor blackColor] colorWithAlphaComponent:0.5].CGColor; + _titleLabel.layer.shadowOffset = CGSizeMake(kShadowOffsetValue, kShadowOffsetValue); + _titleLabel.layer.shadowRadius = 1.5; + } + [self insertSubview:_titleLabel atIndex:3]; + + // Pop animation for touch + if (_popAnimation) { + [self removeGestureRecognizer:_gestureRecognizer]; + _gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pop)]; + [_imgView addGestureRecognizer:_gestureRecognizer]; + } +} + +#pragma mark - Displaying +- (void)show { + [self showInSuperview:[[UIApplication sharedApplication] keyWindow] withCompletion:nil animated:true]; +} + +- (void)showInSuperview:(UIView *)superView withCompletion:(void (^)())completion animated:(bool)animated { + + if (self.btns.count == 0) { + [self applyAppearanceConsideringButtons:false]; + } else { + [self applyAppearanceConsideringButtons:true]; + } + + [self noAlpha]; + + CGFloat animationDuration = 0.0; + animationDuration = animated ? kAnimatingDuration : 0; + + // Blocking views underneath + for (id s in superView.subviews) { + if ([s isMemberOfClass:[JTAlertView class]]) { + [s setUserInteractionEnabled:true]; + } else { + [s setUserInteractionEnabled:false]; + } + } + [superView addSubview:self]; + + // Animation + [UIView animateWithDuration:animationDuration animations:^{ + [self fullAlpha]; + _popAnimation ? [self popAnimationForView:self withDuration:animationDuration] : nil; + + } completion:^(BOOL finished) { + if (completion) { + completion(); + } + }]; +} + +- (void)hide { + [self hideWithCompletion:nil animated:true]; +} + +- (void)hideWithAnimation:(NSNumber *)animated { + bool animation = [animated boolValue]; + [self hideWithCompletion:nil animated:animation]; +} + +- (void)hideWithDelay:(NSTimeInterval)delay animated:(bool)animated { + NSNumber *boolNumber = [NSNumber numberWithBool:animated]; + [self performSelector:@selector(hideWithAnimation:) withObject:boolNumber afterDelay:delay]; +} + +- (void)hideWithCompletion:(void (^)())completion animated:(bool)animated { + CGFloat animationDuration = 0.0; + animationDuration = animated ? kAnimatingDuration : 0; + [UIView animateWithDuration:animationDuration animations:^{ + [self noAlpha]; + [UIView animateWithDuration:animationDuration delay:0.0 options:UIViewAnimationOptionCurveLinear animations:^{ + self.transform = CGAffineTransformMakeScale(0.95, 0.95); + } completion:nil]; + + } completion:^(BOOL finished) { + for (id s in self.superview.subviews) { + [s setUserInteractionEnabled:true]; + } + self.transform = CGAffineTransformMakeScale(1.0, 1.0); + [self removeFromSuperview]; + [_imgView removeFromSuperview]; + [_titleLabel removeFromSuperview]; + if (completion) { + completion(); + } + }]; +} + +#pragma mark - Frame handle +- (CGFloat)screenCenterX { + return [UIScreen mainScreen].bounds.size.width / 2; +} + +- (CGFloat)screenCenterY { + return [UIScreen mainScreen].bounds.size.height / 2; +} + +- (CGRect)alertFrameWithinScreen { + return CGRectMake([self screenCenterX] - (_size.width / 2), [self screenCenterY] - (_size.height / 2), _size.width, _size.height); +} + +- (void)createObservers { + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeFrame) name:UIDeviceOrientationDidChangeNotification object:nil]; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +- (void)changeFrame { + self.frame = [self alertFrameWithinScreen]; +} + +- (void)setSize:(CGSize)size { + _size = size; + [self changeFrame]; +} + +#pragma mark - Others +- (void)defaultSetup { + _popAnimation = true; + _parallaxEffect = true; + _overlayColor = [UIColor colorWithWhite:0.15 alpha:0.75]; + _font = [UIFont fontWithName:@"HelveticaNeue-Medium" size:kTitleFontSize]; + _titleColor = [UIColor whiteColor]; + _titleShadow = true; +} + +- (void)noAlpha { + self.alpha = 0.0; +} + +- (void)fullAlpha { + self.alpha = 1.0; +} + +- (void)applyMotionEffects:(UIView *)view { + if (NSClassFromString(@"UIInterpolatingMotionEffect")) { + UIInterpolatingMotionEffect *horizontalEffect = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis]; + horizontalEffect.minimumRelativeValue = @(-kParallaxEffectDivergence); + horizontalEffect.maximumRelativeValue = @(kParallaxEffectDivergence); + UIInterpolatingMotionEffect *verticalEffect = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis]; + verticalEffect.minimumRelativeValue = @(-kParallaxEffectDivergence); + verticalEffect.maximumRelativeValue = @(kParallaxEffectDivergence); + UIMotionEffectGroup *motionEffectGroup = [[UIMotionEffectGroup alloc] init]; + motionEffectGroup.motionEffects = @[horizontalEffect, verticalEffect]; + [view addMotionEffect:motionEffectGroup]; + } +} + +- (void)popAnimationForView:(UIView *)view withDuration:(CGFloat)duration { + [UIView animateWithDuration:duration * 0.5 animations:^{ + view.transform = CGAffineTransformMakeScale(1.05, 1.05); + }]; + [UIView animateWithDuration:duration * 0.35 delay:duration * 0.5 options:UIViewAnimationOptionCurveLinear animations:^{ + view.transform = CGAffineTransformMakeScale(0.98, 0.98); + } completion:nil]; + [UIView animateWithDuration:duration * 0.15 delay:duration * 0.85 options:UIViewAnimationOptionCurveLinear animations:^{ + view.transform = CGAffineTransformMakeScale(1.0, 1.0); + } completion:nil]; +} + +- (void)pop { + [UIView animateWithDuration:kAnimatingDuration animations:^{ + [self popAnimationForView:self withDuration:kAnimatingDuration]; + } completion:nil]; +} + +- (UIImage *)jt_imageWithColor:(UIColor *)color size:(CGSize)size { + CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height); + UIGraphicsBeginImageContext(rect.size); + CGContextRef context = UIGraphicsGetCurrentContext(); + CGContextSetFillColorWithColor(context, [color CGColor]); + CGContextFillRect(context, rect); + UIImage *createdImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + return createdImage; +} + +- (UIFont *)boldForFont:(UIFont *)font withSize:(CGFloat)size { + NSArray *fontParts = [font.fontName componentsSeparatedByString:@"-"]; + NSString *fontBase = [fontParts firstObject]; + UIFont *newFont = [UIFont fontWithName:[NSString stringWithFormat:@"%@-Bold", fontBase] size:size]; + return newFont; +} + +@end + +#pragma mark - UIBlockButton +@implementation UIBlockButton + +- (void)handleControlEvent:(UIControlEvents)event withBlock:(ActionBlock)action { + _actionBlock = action; + [self addTarget:self action:@selector(callActionBlock) forControlEvents:event]; +} + +- (void)callActionBlock { + _actionBlock((JTAlertView *)self.superview); +} + +@end \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..b60b5f1 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,7 @@ +The MIT License (MIT) +Copyright © 2015 Jakub Truhlar +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100755 index 0000000..57a3916 --- /dev/null +++ b/README.md @@ -0,0 +1,100 @@ +# JTAlertView + +**JTAlertView** is the new **wonderful dialog/HUD/alert** kind of View. It was also designed to cover user’s needs during **customization**. Created with **delightful combination** of image, parallax and pop effects, **JTAlertView** improves your user experience. + +

+ Example +

+ +## Installation +There are two ways to add the **JTImageButton** library to your project. Add it as a regular library or install it through **CocoaPods**. + +`pod 'JTAlertView'` + +You may also quick try the example project with + +`pod try JTAlertView` + +**Library requires target iOS 7.0 and above** + +> **Works in both - Portrait and Landscape modes** + +

+ Parallax       + Example +

+ +## Usage and Customization + +- Use `initWithTitle:andImage:` OR class method `alertWithTitle:andImage:` **to initialize**. +- Then you can use many properties like `overlayColor` **to customize** the **JTAlertView**. +- Then **add the buttons** e.g. `addButtonWithTitle:action:` +- And finally use `show` and `hide` methods **to handle displaying**. + + +### Simple One-button example: +```objective-c +JTAlertView *alertView = [[JTAlertView alloc] initWithTitle:@"You are wonderful" andImage:image]; +self.alertView.size = CGSizeMake(280, 230); + +[self.alertView addButtonWithTitle:@"OK" style:JTAlertViewStyleDefault action:^(JTAlertView *alertView) { + [alertView hide]; +}]; + +[self.alertView show]; +``` + +### Properties: + +You must setup `size` property or the default will be used. `popAnimation` is visible while displaying and if you tap on the dialog. The `overlayColor` above given image and decent `titleShadow` make title better readable. The `font` property (it's `style` and `size`) is applied to title and buttons (`style` only). To customize particular buttons, use `font` parameter in buttons adding methods (*see below*). + +```objective-c +@property (nonatomic, assign) CGSize size; + +@property (nonatomic, assign) bool popAnimation; +@property (nonatomic, assign) bool parallaxEffect; +@property (nonatomic, strong) UIColor *overlayColor; + +@property (nonatomic, strong) UIFont *font; +@property (nonatomic, strong) UIColor *titleColor; +@property (nonatomic, assign) bool titleShadow; +``` + + +### Adding buttons: + +You can setup button's `title`, `actionBlock`, `style` (similar to `UIAlertAction` styles), `controlEvents` and `font` if needed. + +```objective-c +- (void)addButtonWithTitle:action: +- (void)addButtonWithTitle:style:action: +- (void)addButtonWithTitle:style:forControlEvents:action: +- (void)addButtonWithTitle:font:style:forControlEvents:action: +``` + + +### Displaying: + +You can show **JTAlertView** `withCompletion` block, in specific `superview`, `animated` and hide it also with `delay`. + +```objective-c +- (void)show +- (void)showInSuperview:withCompletion:animated: + +- (void)hide +- (void)hideWithCompletion:animated: +- (void)hideWithDelay:animated: +``` + + +## Changelog + +### v1.0.0 - 06.17.15 +- [**NEW**] Initial commit + +## Author +This library is open-sourced by [Jakub Truhlar](http://kubatruhlar.cz). + +## License +The MIT License (MIT) +Copyright © 2015 Jakub Truhlar diff --git a/Screens/alertView.png b/Screens/alertView.png new file mode 100644 index 0000000..0489575 Binary files /dev/null and b/Screens/alertView.png differ diff --git a/Screens/parallax.gif b/Screens/parallax.gif new file mode 100644 index 0000000..8e2d2dc Binary files /dev/null and b/Screens/parallax.gif differ diff --git a/Screens/popanimated.gif b/Screens/popanimated.gif new file mode 100644 index 0000000..361783f Binary files /dev/null and b/Screens/popanimated.gif differ