diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6bd3677 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +RECurtainViewControllerExample.xcodeproj/project.xcworkspace/xcuserdata/roman.xcuserdatad/UserInterfaceState.xcuserstate diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5f278f0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +Copyright © 2012 Roman Efimov (http://github.com/romaonthego). + +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 100644 index 0000000..54d8124 --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# RECurtainViewController +###A custom curtain-style transition for UIViewControllers. + +![Screenshot of RECurtainViewController](https://github.com/romaonthego/RECurtainViewController/raw/master/Screenshot.png "RECurtainViewController Screenshot") + +## Demo + +Build and run the `RECurtainViewControllerExample` project in Xcode to see `RECurtainViewController` in action. + +## Installation + +`RECurtainViewController` requires the `QuartzCore` framework, so the first thing you'll need to do is include the framework into your project. + +Now that the framework has been linked, all you need to do is drop `UIViewController+RECurtainViewController.{h,m}` into your project, and add `#include "UIViewController+RECurtainViewController.h"` to the top of classes that will use it. + +## Example Usage + +``` objective-c +DemoViewController *test = [[DemoViewController alloc] init]; +[self curtainRevealViewController:test + transitionStyle:RECurtainTransitionHorizontal + backgroundColor:[UIColor blackColor]]; +``` + +## Contact + +Roman Efimov + +- http://github.com/romaonthego +- http://twitter.com/romaonthego + +## License + +RECurtainViewController is available under the MIT license. + +Copyright © 2012 Roman Efimov. + +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/RECurtainViewControllerExample.xcodeproj/project.pbxproj b/RECurtainViewControllerExample.xcodeproj/project.pbxproj new file mode 100644 index 0000000..800db4e --- /dev/null +++ b/RECurtainViewControllerExample.xcodeproj/project.pbxproj @@ -0,0 +1,295 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 30BFA95015AA042D00C05D32 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30BFA94F15AA042D00C05D32 /* UIKit.framework */; }; + 30BFA95215AA042D00C05D32 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30BFA95115AA042D00C05D32 /* Foundation.framework */; }; + 30BFA95415AA042D00C05D32 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30BFA95315AA042D00C05D32 /* CoreGraphics.framework */; }; + 30BFA95A15AA042D00C05D32 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 30BFA95815AA042D00C05D32 /* InfoPlist.strings */; }; + 30BFA95C15AA042D00C05D32 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 30BFA95B15AA042D00C05D32 /* main.m */; }; + 30BFA96015AA042D00C05D32 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 30BFA95F15AA042D00C05D32 /* AppDelegate.m */; }; + 30BFA97115AA04F500C05D32 /* UIViewController+RECurtainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 30BFA97015AA04F500C05D32 /* UIViewController+RECurtainViewController.m */; }; + 30BFA97415AA05C700C05D32 /* DemoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 30BFA97315AA05C700C05D32 /* DemoViewController.m */; }; + 30BFA97715AA05D400C05D32 /* CurtainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 30BFA97615AA05D400C05D32 /* CurtainViewController.m */; }; + 30BFA97915AA05E700C05D32 /* wallpaper@2x.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 30BFA97815AA05E700C05D32 /* wallpaper@2x.jpg */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 30BFA94B15AA042D00C05D32 /* RECurtainViewControllerExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RECurtainViewControllerExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 30BFA94F15AA042D00C05D32 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 30BFA95115AA042D00C05D32 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 30BFA95315AA042D00C05D32 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + 30BFA95715AA042D00C05D32 /* RECurtainViewControllerExample-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "RECurtainViewControllerExample-Info.plist"; sourceTree = ""; }; + 30BFA95915AA042D00C05D32 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 30BFA95B15AA042D00C05D32 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 30BFA95D15AA042D00C05D32 /* RECurtainViewControllerExample-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RECurtainViewControllerExample-Prefix.pch"; sourceTree = ""; }; + 30BFA95E15AA042D00C05D32 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 30BFA95F15AA042D00C05D32 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 30BFA96F15AA04F500C05D32 /* UIViewController+RECurtainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+RECurtainViewController.h"; sourceTree = ""; }; + 30BFA97015AA04F500C05D32 /* UIViewController+RECurtainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+RECurtainViewController.m"; sourceTree = ""; }; + 30BFA97215AA05C700C05D32 /* DemoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemoViewController.h; sourceTree = ""; }; + 30BFA97315AA05C700C05D32 /* DemoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoViewController.m; sourceTree = ""; }; + 30BFA97515AA05D400C05D32 /* CurtainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CurtainViewController.h; sourceTree = ""; }; + 30BFA97615AA05D400C05D32 /* CurtainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CurtainViewController.m; sourceTree = ""; }; + 30BFA97815AA05E700C05D32 /* wallpaper@2x.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "wallpaper@2x.jpg"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 30BFA94815AA042D00C05D32 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 30BFA95015AA042D00C05D32 /* UIKit.framework in Frameworks */, + 30BFA95215AA042D00C05D32 /* Foundation.framework in Frameworks */, + 30BFA95415AA042D00C05D32 /* CoreGraphics.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 30BFA94015AA042D00C05D32 = { + isa = PBXGroup; + children = ( + 30BFA96E15AA04F500C05D32 /* Source */, + 30BFA95515AA042D00C05D32 /* RECurtainViewControllerExample */, + 30BFA94E15AA042D00C05D32 /* Frameworks */, + 30BFA94C15AA042D00C05D32 /* Products */, + ); + sourceTree = ""; + }; + 30BFA94C15AA042D00C05D32 /* Products */ = { + isa = PBXGroup; + children = ( + 30BFA94B15AA042D00C05D32 /* RECurtainViewControllerExample.app */, + ); + name = Products; + sourceTree = ""; + }; + 30BFA94E15AA042D00C05D32 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 30BFA94F15AA042D00C05D32 /* UIKit.framework */, + 30BFA95115AA042D00C05D32 /* Foundation.framework */, + 30BFA95315AA042D00C05D32 /* CoreGraphics.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 30BFA95515AA042D00C05D32 /* RECurtainViewControllerExample */ = { + isa = PBXGroup; + children = ( + 30BFA95615AA042D00C05D32 /* Supporting Files */, + 30BFA95E15AA042D00C05D32 /* AppDelegate.h */, + 30BFA95F15AA042D00C05D32 /* AppDelegate.m */, + 30BFA97215AA05C700C05D32 /* DemoViewController.h */, + 30BFA97315AA05C700C05D32 /* DemoViewController.m */, + 30BFA97515AA05D400C05D32 /* CurtainViewController.h */, + 30BFA97615AA05D400C05D32 /* CurtainViewController.m */, + ); + path = RECurtainViewControllerExample; + sourceTree = ""; + }; + 30BFA95615AA042D00C05D32 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 30BFA97815AA05E700C05D32 /* wallpaper@2x.jpg */, + 30BFA95715AA042D00C05D32 /* RECurtainViewControllerExample-Info.plist */, + 30BFA95815AA042D00C05D32 /* InfoPlist.strings */, + 30BFA95B15AA042D00C05D32 /* main.m */, + 30BFA95D15AA042D00C05D32 /* RECurtainViewControllerExample-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 30BFA96E15AA04F500C05D32 /* Source */ = { + isa = PBXGroup; + children = ( + 30BFA96F15AA04F500C05D32 /* UIViewController+RECurtainViewController.h */, + 30BFA97015AA04F500C05D32 /* UIViewController+RECurtainViewController.m */, + ); + path = Source; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 30BFA94A15AA042D00C05D32 /* RECurtainViewControllerExample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 30BFA96315AA042D00C05D32 /* Build configuration list for PBXNativeTarget "RECurtainViewControllerExample" */; + buildPhases = ( + 30BFA94715AA042D00C05D32 /* Sources */, + 30BFA94815AA042D00C05D32 /* Frameworks */, + 30BFA94915AA042D00C05D32 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = RECurtainViewControllerExample; + productName = RECurtainViewControllerExample; + productReference = 30BFA94B15AA042D00C05D32 /* RECurtainViewControllerExample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 30BFA94215AA042D00C05D32 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0430; + ORGANIZATIONNAME = "Roman Efimov"; + }; + buildConfigurationList = 30BFA94515AA042D00C05D32 /* Build configuration list for PBXProject "RECurtainViewControllerExample" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 30BFA94015AA042D00C05D32; + productRefGroup = 30BFA94C15AA042D00C05D32 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 30BFA94A15AA042D00C05D32 /* RECurtainViewControllerExample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 30BFA94915AA042D00C05D32 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 30BFA95A15AA042D00C05D32 /* InfoPlist.strings in Resources */, + 30BFA97915AA05E700C05D32 /* wallpaper@2x.jpg in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 30BFA94715AA042D00C05D32 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 30BFA95C15AA042D00C05D32 /* main.m in Sources */, + 30BFA96015AA042D00C05D32 /* AppDelegate.m in Sources */, + 30BFA97115AA04F500C05D32 /* UIViewController+RECurtainViewController.m in Sources */, + 30BFA97415AA05C700C05D32 /* DemoViewController.m in Sources */, + 30BFA97715AA05D400C05D32 /* CurtainViewController.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 30BFA95815AA042D00C05D32 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 30BFA95915AA042D00C05D32 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 30BFA96115AA042D00C05D32 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + 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_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 30BFA96215AA042D00C05D32 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 30BFA96415AA042D00C05D32 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "RECurtainViewControllerExample/RECurtainViewControllerExample-Prefix.pch"; + INFOPLIST_FILE = "RECurtainViewControllerExample/RECurtainViewControllerExample-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + 30BFA96515AA042D00C05D32 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "RECurtainViewControllerExample/RECurtainViewControllerExample-Prefix.pch"; + INFOPLIST_FILE = "RECurtainViewControllerExample/RECurtainViewControllerExample-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 30BFA94515AA042D00C05D32 /* Build configuration list for PBXProject "RECurtainViewControllerExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 30BFA96115AA042D00C05D32 /* Debug */, + 30BFA96215AA042D00C05D32 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 30BFA96315AA042D00C05D32 /* Build configuration list for PBXNativeTarget "RECurtainViewControllerExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 30BFA96415AA042D00C05D32 /* Debug */, + 30BFA96515AA042D00C05D32 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 30BFA94215AA042D00C05D32 /* Project object */; +} diff --git a/RECurtainViewControllerExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/RECurtainViewControllerExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..a89bd35 --- /dev/null +++ b/RECurtainViewControllerExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/RECurtainViewControllerExample.xcodeproj/project.xcworkspace/xcuserdata/roman.xcuserdatad/WorkspaceSettings.xcsettings b/RECurtainViewControllerExample.xcodeproj/project.xcworkspace/xcuserdata/roman.xcuserdatad/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..bfffcfe --- /dev/null +++ b/RECurtainViewControllerExample.xcodeproj/project.xcworkspace/xcuserdata/roman.xcuserdatad/WorkspaceSettings.xcsettings @@ -0,0 +1,10 @@ + + + + + HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges + + SnapshotAutomaticallyBeforeSignificantChanges + + + diff --git a/RECurtainViewControllerExample.xcodeproj/xcuserdata/roman.xcuserdatad/xcschemes/RECurtainViewControllerExample.xcscheme b/RECurtainViewControllerExample.xcodeproj/xcuserdata/roman.xcuserdatad/xcschemes/RECurtainViewControllerExample.xcscheme new file mode 100644 index 0000000..e8fe470 --- /dev/null +++ b/RECurtainViewControllerExample.xcodeproj/xcuserdata/roman.xcuserdatad/xcschemes/RECurtainViewControllerExample.xcscheme @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RECurtainViewControllerExample.xcodeproj/xcuserdata/roman.xcuserdatad/xcschemes/xcschememanagement.plist b/RECurtainViewControllerExample.xcodeproj/xcuserdata/roman.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..34d9da2 --- /dev/null +++ b/RECurtainViewControllerExample.xcodeproj/xcuserdata/roman.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + RECurtainViewControllerExample.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 30BFA94A15AA042D00C05D32 + + primary + + + + + diff --git a/RECurtainViewControllerExample/AppDelegate.h b/RECurtainViewControllerExample/AppDelegate.h new file mode 100644 index 0000000..d269791 --- /dev/null +++ b/RECurtainViewControllerExample/AppDelegate.h @@ -0,0 +1,15 @@ +// +// AppDelegate.h +// RECurtainViewControllerExample +// +// Created by Roman Efimov on 7/8/12. +// Copyright (c) 2012 Roman Efimov. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@end diff --git a/RECurtainViewControllerExample/AppDelegate.m b/RECurtainViewControllerExample/AppDelegate.m new file mode 100644 index 0000000..4b12edd --- /dev/null +++ b/RECurtainViewControllerExample/AppDelegate.m @@ -0,0 +1,53 @@ +// +// AppDelegate.m +// RECurtainViewControllerExample +// +// Created by Roman Efimov on 7/8/12. +// Copyright (c) 2012 Roman Efimov. All rights reserved. +// + +#import "AppDelegate.h" +#import "CurtainViewController.h" + +@implementation AppDelegate + +@synthesize window = _window; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + // Override point for customization after application launch. + self.window.rootViewController = [[CurtainViewController alloc] init]; + self.window.backgroundColor = [UIColor whiteColor]; + [self.window makeKeyAndVisible]; + 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/RECurtainViewControllerExample/CurtainViewController.h b/RECurtainViewControllerExample/CurtainViewController.h new file mode 100644 index 0000000..2b78e74 --- /dev/null +++ b/RECurtainViewControllerExample/CurtainViewController.h @@ -0,0 +1,14 @@ +// +// CurtainViewController.h +// RECurtainViewControllerExample +// +// Created by Roman Efimov on 7/8/12. +// Copyright (c) 2012 Roman Efimov. All rights reserved. +// + +#import +#import "UIViewController+RECurtainViewController.h" + +@interface CurtainViewController : UIViewController + +@end diff --git a/RECurtainViewControllerExample/CurtainViewController.m b/RECurtainViewControllerExample/CurtainViewController.m new file mode 100644 index 0000000..c028ff9 --- /dev/null +++ b/RECurtainViewControllerExample/CurtainViewController.m @@ -0,0 +1,72 @@ +// +// CurtainViewController.m +// RECurtainViewControllerExample +// +// Created by Roman Efimov on 7/8/12. +// Copyright (c) 2012 Roman Efimov. All rights reserved. +// + +#import "CurtainViewController.h" +#import "DemoViewController.h" + +@interface CurtainViewController () + +@end + +@implementation CurtainViewController + +- (void)dismissHorizontalPressed +{ + DemoViewController *test = [[DemoViewController alloc] init]; + [self curtainRevealViewController:test + transitionStyle:RECurtainTransitionHorizontal + backgroundColor:[UIColor blackColor]]; +} + +- (void)dismissVerticalPressed +{ + DemoViewController *test = [[DemoViewController alloc] init]; + [self curtainRevealViewController:test + transitionStyle:RECurtainTransitionVertical + backgroundColor:[UIColor blackColor]]; +} + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"wallpaper.jpg"]]; + + UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + button.frame = CGRectMake(60, 170, 200, 44); + [button setTitle:@"Dismiss Horizontal" forState:UIControlStateNormal]; + [button addTarget:self action:@selector(dismissHorizontalPressed) forControlEvents:UIControlEventTouchUpInside]; + [self.view addSubview:button]; + + button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + button.frame = CGRectMake(60, 220, 200, 44); + [button setTitle:@"Dismiss Vertical" forState:UIControlStateNormal]; + [button addTarget:self action:@selector(dismissVerticalPressed) forControlEvents:UIControlEventTouchUpInside]; + [self.view addSubview:button]; + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view. +} + +- (void)viewDidUnload +{ + [super viewDidUnload]; + // Release any retained subviews of the main view. +} + +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation +{ + return (interfaceOrientation == UIInterfaceOrientationPortrait); +} + +@end diff --git a/RECurtainViewControllerExample/DemoViewController.h b/RECurtainViewControllerExample/DemoViewController.h new file mode 100644 index 0000000..95e73a5 --- /dev/null +++ b/RECurtainViewControllerExample/DemoViewController.h @@ -0,0 +1,13 @@ +// +// DemoViewController.h +// RECurtainViewControllerExample +// +// Created by Roman Efimov on 7/8/12. +// Copyright (c) 2012 Roman Efimov. All rights reserved. +// + +#import + +@interface DemoViewController : UIViewController + +@end diff --git a/RECurtainViewControllerExample/DemoViewController.m b/RECurtainViewControllerExample/DemoViewController.m new file mode 100644 index 0000000..1caaca2 --- /dev/null +++ b/RECurtainViewControllerExample/DemoViewController.m @@ -0,0 +1,55 @@ +// +// DemoViewController.m +// RECurtainViewControllerExample +// +// Created by Roman Efimov on 7/8/12. +// Copyright (c) 2012 Roman Efimov. All rights reserved. +// + +#import "DemoViewController.h" + +@interface DemoViewController () + +@end + +@implementation DemoViewController + +- (void)buttonPressed +{ + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Hi" message:@"Test" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alertView show]; +} + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + self.view.backgroundColor = [UIColor greenColor]; + + UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + button.frame = CGRectMake(60, 100, 200, 44); + [button setTitle:@"Test button" forState:UIControlStateNormal]; + [button addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside]; + [self.view addSubview:button]; + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view. +} + +- (void)viewDidUnload +{ + [super viewDidUnload]; + // Release any retained subviews of the main view. +} + +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation +{ + return (interfaceOrientation == UIInterfaceOrientationPortrait); +} + +@end diff --git a/RECurtainViewControllerExample/RECurtainViewControllerExample-Info.plist b/RECurtainViewControllerExample/RECurtainViewControllerExample-Info.plist new file mode 100644 index 0000000..30e4991 --- /dev/null +++ b/RECurtainViewControllerExample/RECurtainViewControllerExample-Info.plist @@ -0,0 +1,38 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.yourcompany.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/RECurtainViewControllerExample/RECurtainViewControllerExample-Prefix.pch b/RECurtainViewControllerExample/RECurtainViewControllerExample-Prefix.pch new file mode 100644 index 0000000..f5e95bc --- /dev/null +++ b/RECurtainViewControllerExample/RECurtainViewControllerExample-Prefix.pch @@ -0,0 +1,14 @@ +// +// Prefix header for all source files of the 'RECurtainViewControllerExample' target in the 'RECurtainViewControllerExample' project +// + +#import + +#ifndef __IPHONE_3_0 +#warning "This project uses features only available in iOS SDK 3.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/RECurtainViewControllerExample/en.lproj/InfoPlist.strings b/RECurtainViewControllerExample/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/RECurtainViewControllerExample/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/RECurtainViewControllerExample/main.m b/RECurtainViewControllerExample/main.m new file mode 100644 index 0000000..2ff6639 --- /dev/null +++ b/RECurtainViewControllerExample/main.m @@ -0,0 +1,18 @@ +// +// main.m +// RECurtainViewControllerExample +// +// Created by Roman Efimov on 7/8/12. +// Copyright (c) 2012 Roman Efimov. 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/RECurtainViewControllerExample/wallpaper@2x.jpg b/RECurtainViewControllerExample/wallpaper@2x.jpg new file mode 100644 index 0000000..bb50c73 Binary files /dev/null and b/RECurtainViewControllerExample/wallpaper@2x.jpg differ diff --git a/Screenshot.png b/Screenshot.png new file mode 100644 index 0000000..025bf19 Binary files /dev/null and b/Screenshot.png differ diff --git a/Source/UIViewController+RECurtainViewController.h b/Source/UIViewController+RECurtainViewController.h new file mode 100644 index 0000000..f91458b --- /dev/null +++ b/Source/UIViewController+RECurtainViewController.h @@ -0,0 +1,36 @@ +// +// UIViewController+RECurtainViewController.h +// +// Copyright (c) 2012 Roman Efimov (http://github.com/romaonthego) +// +// 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. + +#import +#import + +typedef enum _RECurtainTransitionStyle { + RECurtainTransitionHorizontal = 0, + RECurtainTransitionVertical = 1 +} RECurtainTransitionStyle; + +@interface UIViewController (RECurtainViewController) + +- (void)curtainRevealViewController:(UIViewController *)viewControllerToReveal transitionStyle:(RECurtainTransitionStyle)transitionStyle backgroundColor:(UIColor *)backgroundColor; + +@end diff --git a/Source/UIViewController+RECurtainViewController.m b/Source/UIViewController+RECurtainViewController.m new file mode 100644 index 0000000..dcaa362 --- /dev/null +++ b/Source/UIViewController+RECurtainViewController.m @@ -0,0 +1,95 @@ +// +// UIViewController+RECurtainViewController.m +// +// Copyright (c) 2012 Roman Efimov (http://github.com/romaonthego) +// +// 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. + +#import "UIViewController+RECurtainViewController.h" +#import "AppDelegate.h" + +@implementation UIViewController (RECurtainViewController) + +- (UIImage *)imageWithView:(UIView *)view +{ + UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0); + [view.layer renderInContext:UIGraphicsGetCurrentContext()]; + UIImage * img = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + return img; +} + +- (void)curtainRevealViewController:(UIViewController *)viewControllerToReveal transitionStyle:(RECurtainTransitionStyle)transitionStyle backgroundColor:(UIColor *)backgroundColor +{ + UIImage *selfPortrait = [self imageWithView:self.view]; + UIImage *controllerScreenshot = [self imageWithView:viewControllerToReveal.view]; + + UIView *coverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; + coverView.backgroundColor = backgroundColor; + [self.view addSubview:coverView]; + + UIImageView *fadedView = [[UIImageView alloc] initWithFrame:CGRectMake(30, 30, self.view.frame.size.width - 60, self.view.frame.size.height - 60)]; + fadedView.image = controllerScreenshot; + fadedView.alpha = 0.4; + [coverView addSubview:fadedView]; + + UIImageView *leftCurtain = [[UIImageView alloc] initWithFrame:CGRectNull]; + leftCurtain.image = selfPortrait; + leftCurtain.clipsToBounds = YES; + + CGRect rightFrame = CGRectMake(self.view.frame.size.width / 2, 0, self.view.frame.size.width / 2, self.view.frame.size.height); + UIImageView *rightCurtain = [[UIImageView alloc] initWithFrame:rightFrame]; + rightCurtain.image = selfPortrait; + rightCurtain.clipsToBounds = YES; + + if (transitionStyle == RECurtainTransitionHorizontal) { + leftCurtain.contentMode = UIViewContentModeLeft; + leftCurtain.frame = CGRectMake(0, 0, self.view.frame.size.width / 2, self.view.frame.size.height); + rightCurtain.contentMode = UIViewContentModeRight; + rightCurtain.frame = CGRectMake(self.view.frame.size.width / 2, 0, self.view.frame.size.width / 2, self.view.frame.size.height); + } else { + leftCurtain.contentMode = UIViewContentModeTop; + leftCurtain.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height / 2); + rightCurtain.contentMode = UIViewContentModeBottom; + rightCurtain.frame = CGRectMake(0, self.view.frame.size.height / 2, self.view.frame.size.width, self.view.frame.size.height / 2); + } + + [coverView addSubview:leftCurtain]; + [coverView addSubview:rightCurtain]; + + [UIView animateWithDuration:0.7 delay:0 options:UIViewAnimationCurveEaseIn animations:^{ + if (transitionStyle == RECurtainTransitionHorizontal) { + leftCurtain.frame = CGRectMake(- self.view.frame.size.width / 2, 0, self.view.frame.size.width / 2, self.view.frame.size.height); + rightCurtain.frame = CGRectMake(self.view.frame.size.width, 0, self.view.frame.size.width / 2, self.view.frame.size.height); + } else { + leftCurtain.frame = CGRectMake(0, - self.view.frame.size.height / 2, self.view.frame.size.width, self.view.frame.size.height / 2); + rightCurtain.frame = CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, self.view.frame.size.height / 2); + } + } completion:nil]; + + [UIView animateWithDuration:0.3 delay:0.5 options:UIViewAnimationCurveEaseIn animations:^{ + fadedView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); + fadedView.alpha = 1; + } completion:^(BOOL finished){ + AppDelegate *appDelegate = [UIApplication sharedApplication].delegate; + appDelegate.window.rootViewController = viewControllerToReveal; + }]; +} + +@end