diff --git a/PaperFold/PaperFold.xcodeproj/project.pbxproj b/PaperFold/PaperFold.xcodeproj/project.pbxproj index 0ebada3..61b8607 100644 --- a/PaperFold/PaperFold.xcodeproj/project.pbxproj +++ b/PaperFold/PaperFold.xcodeproj/project.pbxproj @@ -7,6 +7,29 @@ objects = { /* Begin PBXBuildFile section */ + DAE7DB86168207EA00C3E7FB /* SinglePaperFoldView.m in Sources */ = {isa = PBXBuildFile; fileRef = DAE7DB85168207EA00C3E7FB /* SinglePaperFoldView.m */; }; + DAE7DB9416821B8900C3E7FB /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F8C45D9314DF822D00F12A1D /* main.m */; }; + DAE7DB9516821B8900C3E7FB /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F8C45D9714DF822D00F12A1D /* AppDelegate.m */; }; + DAE7DB9716821B8900C3E7FB /* FacingView.m in Sources */ = {isa = PBXBuildFile; fileRef = F877BEF414E2B5F20076B1C6 /* FacingView.m */; }; + DAE7DB9816821B8900C3E7FB /* FoldView.m in Sources */ = {isa = PBXBuildFile; fileRef = F877BEF614E2B5F20076B1C6 /* FoldView.m */; }; + DAE7DB9916821B8900C3E7FB /* MultiFoldView.m in Sources */ = {isa = PBXBuildFile; fileRef = F877BEF814E2B5F20076B1C6 /* MultiFoldView.m */; }; + DAE7DB9A16821B8900C3E7FB /* PaperFoldView.m in Sources */ = {isa = PBXBuildFile; fileRef = F877BEFA14E2B5F20076B1C6 /* PaperFoldView.m */; }; + DAE7DB9B16821B8900C3E7FB /* ShadowView.m in Sources */ = {isa = PBXBuildFile; fileRef = F877BEFC14E2B5F20076B1C6 /* ShadowView.m */; }; + DAE7DB9C16821B8900C3E7FB /* TouchThroughUIView.m in Sources */ = {isa = PBXBuildFile; fileRef = F877BEFE14E2B5F20076B1C6 /* TouchThroughUIView.m */; }; + DAE7DB9D16821B8900C3E7FB /* UIView+Screenshot.m in Sources */ = {isa = PBXBuildFile; fileRef = F877BF0014E2B5F20076B1C6 /* UIView+Screenshot.m */; }; + DAE7DB9E16821B8900C3E7FB /* SinglePaperFoldView.m in Sources */ = {isa = PBXBuildFile; fileRef = DAE7DB85168207EA00C3E7FB /* SinglePaperFoldView.m */; }; + DAE7DBA016821B8900C3E7FB /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8DB47B214E0A68E00067048 /* CoreLocation.framework */; }; + DAE7DBA116821B8900C3E7FB /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8DB47AC14E0A41400067048 /* MapKit.framework */; }; + DAE7DBA216821B8900C3E7FB /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8C45DA114DF848700F12A1D /* QuartzCore.framework */; }; + DAE7DBA316821B8900C3E7FB /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8C45D8714DF822D00F12A1D /* UIKit.framework */; }; + DAE7DBA416821B8900C3E7FB /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8C45D8914DF822D00F12A1D /* Foundation.framework */; }; + DAE7DBA516821B8900C3E7FB /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8C45D8B14DF822D00F12A1D /* CoreGraphics.framework */; }; + DAE7DBA716821B8900C3E7FB /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = F8C45D9014DF822D00F12A1D /* InfoPlist.strings */; }; + DAE7DBA816821B8900C3E7FB /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F82A503E1634C512005E7244 /* Default-568h@2x.png */; }; + DAE7DBB016821BCF00C3E7FB /* SinglePaperFold-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = DAE7DBAF16821BCF00C3E7FB /* SinglePaperFold-Info.plist */; }; + DAE7DBB91682215300C3E7FB /* SinglePaperViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DAE7DBB71682215200C3E7FB /* SinglePaperViewController.m */; }; + DAE7DBBA1682215300C3E7FB /* SinglePaperViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = DAE7DBB81682215200C3E7FB /* SinglePaperViewController.xib */; }; + DAE7DBBE1682289600C3E7FB /* miao.png in Resources */ = {isa = PBXBuildFile; fileRef = DAE7DBBD1682289600C3E7FB /* miao.png */; }; F82A503F1634C512005E7244 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F82A503E1634C512005E7244 /* Default-568h@2x.png */; }; F877BF0114E2B5F20076B1C6 /* FacingView.m in Sources */ = {isa = PBXBuildFile; fileRef = F877BEF414E2B5F20076B1C6 /* FacingView.m */; }; F877BF0214E2B5F20076B1C6 /* FoldView.m in Sources */ = {isa = PBXBuildFile; fileRef = F877BEF614E2B5F20076B1C6 /* FoldView.m */; }; @@ -28,8 +51,16 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - F84CDB2A15E917C500DBA1C1 /* PaperFoldConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PaperFoldConstants.h; sourceTree = ""; }; + DAE7DB84168207EA00C3E7FB /* SinglePaperFoldView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SinglePaperFoldView.h; sourceTree = ""; }; + DAE7DB85168207EA00C3E7FB /* SinglePaperFoldView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SinglePaperFoldView.m; sourceTree = ""; }; + DAE7DBAC16821B8900C3E7FB /* SinglePaperFold.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SinglePaperFold.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DAE7DBAF16821BCF00C3E7FB /* SinglePaperFold-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "SinglePaperFold-Info.plist"; sourceTree = ""; }; + DAE7DBB61682215200C3E7FB /* SinglePaperViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SinglePaperViewController.h; sourceTree = ""; }; + DAE7DBB71682215200C3E7FB /* SinglePaperViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SinglePaperViewController.m; sourceTree = ""; }; + DAE7DBB81682215200C3E7FB /* SinglePaperViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SinglePaperViewController.xib; sourceTree = ""; }; + DAE7DBBD1682289600C3E7FB /* miao.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = miao.png; path = PaperFold/Resources/miao.png; sourceTree = ""; }; F82A503E1634C512005E7244 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + F84CDB2A15E917C500DBA1C1 /* PaperFoldConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PaperFoldConstants.h; sourceTree = ""; }; F877BEF314E2B5F20076B1C6 /* FacingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FacingView.h; sourceTree = ""; }; F877BEF414E2B5F20076B1C6 /* FacingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FacingView.m; sourceTree = ""; }; F877BEF514E2B5F20076B1C6 /* FoldView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FoldView.h; sourceTree = ""; }; @@ -62,6 +93,19 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + DAE7DB9F16821B8900C3E7FB /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + DAE7DBA016821B8900C3E7FB /* CoreLocation.framework in Frameworks */, + DAE7DBA116821B8900C3E7FB /* MapKit.framework in Frameworks */, + DAE7DBA216821B8900C3E7FB /* QuartzCore.framework in Frameworks */, + DAE7DBA316821B8900C3E7FB /* UIKit.framework in Frameworks */, + DAE7DBA416821B8900C3E7FB /* Foundation.framework in Frameworks */, + DAE7DBA516821B8900C3E7FB /* CoreGraphics.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; F8C45D8014DF822D00F12A1D /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -96,6 +140,8 @@ F877BEFF14E2B5F20076B1C6 /* UIView+Screenshot.h */, F877BF0014E2B5F20076B1C6 /* UIView+Screenshot.m */, F84CDB2A15E917C500DBA1C1 /* PaperFoldConstants.h */, + DAE7DB84168207EA00C3E7FB /* SinglePaperFoldView.h */, + DAE7DB85168207EA00C3E7FB /* SinglePaperFoldView.m */, ); path = PaperFold; sourceTree = ""; @@ -114,6 +160,7 @@ isa = PBXGroup; children = ( F8C45D8314DF822D00F12A1D /* PaperFold.app */, + DAE7DBAC16821B8900C3E7FB /* SinglePaperFold.app */, ); name = Products; sourceTree = ""; @@ -138,6 +185,9 @@ F8C45D9714DF822D00F12A1D /* AppDelegate.m */, F8DB47A814E0A3E400067048 /* DemoRootViewController.h */, F8DB47A914E0A3E400067048 /* DemoRootViewController.m */, + DAE7DBB61682215200C3E7FB /* SinglePaperViewController.h */, + DAE7DBB71682215200C3E7FB /* SinglePaperViewController.m */, + DAE7DBB81682215200C3E7FB /* SinglePaperViewController.xib */, F877BEF214E2B5F20076B1C6 /* PaperFold */, F8C45D8E14DF822D00F12A1D /* Supporting Files */, ); @@ -147,6 +197,8 @@ F8C45D8E14DF822D00F12A1D /* Supporting Files */ = { isa = PBXGroup; children = ( + DAE7DBBD1682289600C3E7FB /* miao.png */, + DAE7DBAF16821BCF00C3E7FB /* SinglePaperFold-Info.plist */, F8C45D8F14DF822D00F12A1D /* PaperFold-Info.plist */, F8C45D9014DF822D00F12A1D /* InfoPlist.strings */, F8C45D9314DF822D00F12A1D /* main.m */, @@ -158,6 +210,23 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + DAE7DB9216821B8900C3E7FB /* SinglePaperFold */ = { + isa = PBXNativeTarget; + buildConfigurationList = DAE7DBA916821B8900C3E7FB /* Build configuration list for PBXNativeTarget "SinglePaperFold" */; + buildPhases = ( + DAE7DB9316821B8900C3E7FB /* Sources */, + DAE7DB9F16821B8900C3E7FB /* Frameworks */, + DAE7DBA616821B8900C3E7FB /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SinglePaperFold; + productName = PaperFold; + productReference = DAE7DBAC16821B8900C3E7FB /* SinglePaperFold.app */; + productType = "com.apple.product-type.application"; + }; F8C45D8214DF822D00F12A1D /* PaperFold */ = { isa = PBXNativeTarget; buildConfigurationList = F8C45D9B14DF822D00F12A1D /* Build configuration list for PBXNativeTarget "PaperFold" */; @@ -197,11 +266,24 @@ projectRoot = ""; targets = ( F8C45D8214DF822D00F12A1D /* PaperFold */, + DAE7DB9216821B8900C3E7FB /* SinglePaperFold */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + DAE7DBA616821B8900C3E7FB /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DAE7DBA716821B8900C3E7FB /* InfoPlist.strings in Resources */, + DAE7DBA816821B8900C3E7FB /* Default-568h@2x.png in Resources */, + DAE7DBB016821BCF00C3E7FB /* SinglePaperFold-Info.plist in Resources */, + DAE7DBBA1682215300C3E7FB /* SinglePaperViewController.xib in Resources */, + DAE7DBBE1682289600C3E7FB /* miao.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; F8C45D8114DF822D00F12A1D /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -214,6 +296,24 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + DAE7DB9316821B8900C3E7FB /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DAE7DB9416821B8900C3E7FB /* main.m in Sources */, + DAE7DB9516821B8900C3E7FB /* AppDelegate.m in Sources */, + DAE7DB9716821B8900C3E7FB /* FacingView.m in Sources */, + DAE7DB9816821B8900C3E7FB /* FoldView.m in Sources */, + DAE7DB9916821B8900C3E7FB /* MultiFoldView.m in Sources */, + DAE7DB9A16821B8900C3E7FB /* PaperFoldView.m in Sources */, + DAE7DB9B16821B8900C3E7FB /* ShadowView.m in Sources */, + DAE7DB9C16821B8900C3E7FB /* TouchThroughUIView.m in Sources */, + DAE7DB9D16821B8900C3E7FB /* UIView+Screenshot.m in Sources */, + DAE7DB9E16821B8900C3E7FB /* SinglePaperFoldView.m in Sources */, + DAE7DBB91682215300C3E7FB /* SinglePaperViewController.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; F8C45D7F14DF822D00F12A1D /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -228,6 +328,7 @@ F877BF0514E2B5F20076B1C6 /* ShadowView.m in Sources */, F877BF0614E2B5F20076B1C6 /* TouchThroughUIView.m in Sources */, F877BF0714E2B5F20076B1C6 /* UIView+Screenshot.m in Sources */, + DAE7DB86168207EA00C3E7FB /* SinglePaperFoldView.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -245,6 +346,37 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + DAE7DBAA16821B8900C3E7FB /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "PaperFold/PaperFold-Prefix.pch"; + INFOPLIST_FILE = "$(SRCROOT)/PaperFold/SinglePaperFold-Info.plist"; + OTHER_CFLAGS = "-DSINGLE_PAPER_FOLD"; + PRODUCT_NAME = SinglePaperFold; + RUN_CLANG_STATIC_ANALYZER = YES; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + DAE7DBAB16821B8900C3E7FB /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: buUuk private limited"; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "PaperFold/PaperFold-Prefix.pch"; + INFOPLIST_FILE = "$(SRCROOT)/PaperFold/SinglePaperFold-Info.plist"; + OTHER_CFLAGS = ( + "-DNS_BLOCK_ASSERTIONS=1", + "-DSINGLE_PAPER_FOLD", + ); + PRODUCT_NAME = SinglePaperFold; + "PROVISIONING_PROFILE[sdk=iphoneos*]" = "9806D7FE-4AB9-493C-AD7B-ED64E700C58C"; + RUN_CLANG_STATIC_ANALYZER = NO; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; F8C45D9914DF822D00F12A1D /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -319,6 +451,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + DAE7DBA916821B8900C3E7FB /* Build configuration list for PBXNativeTarget "SinglePaperFold" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DAE7DBAA16821B8900C3E7FB /* Debug */, + DAE7DBAB16821B8900C3E7FB /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; F8C45D7D14DF822C00F12A1D /* Build configuration list for PBXProject "PaperFold" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/PaperFold/PaperFold/AppDelegate.m b/PaperFold/PaperFold/AppDelegate.m index d60f186..a9e1668 100644 --- a/PaperFold/PaperFold/AppDelegate.m +++ b/PaperFold/PaperFold/AppDelegate.m @@ -9,6 +9,10 @@ #import "AppDelegate.h" #import "DemoRootViewController.h" +#ifdef SINGLE_PAPER_FOLD +#import "SinglePaperViewController.h" +#endif + @implementation AppDelegate @synthesize window = _window; @@ -20,7 +24,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; +#ifdef SINGLE_PAPER_FOLD + SinglePaperViewController *paper = [[SinglePaperViewController alloc] initWithNibName:@"SinglePaperViewController" bundle:nil]; +#else DemoRootViewController *paper = [[DemoRootViewController alloc] init]; +#endif UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:paper]; [navController setNavigationBarHidden:YES]; [self.window setRootViewController:navController]; diff --git a/PaperFold/PaperFold/PaperFold/FoldView.h b/PaperFold/PaperFold/PaperFold/FoldView.h index b17ebef..57e2b86 100644 --- a/PaperFold/PaperFold/PaperFold/FoldView.h +++ b/PaperFold/PaperFold/PaperFold/FoldView.h @@ -56,6 +56,9 @@ - (id)initWithFrame:(CGRect)frame foldDirection:(FoldDirection)foldDirection; +// the real size of the view +- (CGSize)realSize; + // unfold the 2 facing views using a fraction 0 to 1 // 0 when it's completely folded // 1 when it's completely unfolded diff --git a/PaperFold/PaperFold/PaperFold/FoldView.m b/PaperFold/PaperFold/PaperFold/FoldView.m index 158af36..0990330 100644 --- a/PaperFold/PaperFold/PaperFold/FoldView.m +++ b/PaperFold/PaperFold/PaperFold/FoldView.m @@ -47,7 +47,7 @@ - (id)initWithFrame:(CGRect)frame foldDirection:(FoldDirection)foldDirection { self = [super initWithFrame:frame]; if (self) { - + self.backgroundColor = [UIColor clearColor]; _useOptimizedScreenshot = YES; _foldDirection = foldDirection; @@ -69,6 +69,7 @@ - (id)initWithFrame:(CGRect)frame foldDirection:(FoldDirection)foldDirection [_leftView.layer setAnchorPoint:CGPointMake(0.0, 0.5)]; [self addSubview:_leftView]; [_leftView.shadowView setColorArrays:[NSArray arrayWithObjects:[UIColor colorWithWhite:0 alpha:0.05],[UIColor colorWithWhite:0 alpha:0.6], nil]]; + _leftView.backgroundColor = [UIColor clearColor]; // set anchor point of the rightView to the right edge _rightView = [[FacingView alloc] initWithFrame:CGRectMake(-1*frame.size.width/4,0,frame.size.width/2,frame.size.height)]; @@ -76,6 +77,7 @@ - (id)initWithFrame:(CGRect)frame foldDirection:(FoldDirection)foldDirection [_rightView.layer setAnchorPoint:CGPointMake(1.0, 0.5)]; [self addSubview:_rightView]; [_rightView.shadowView setColorArrays:[NSArray arrayWithObjects:[UIColor colorWithWhite:0 alpha:0.9],[UIColor colorWithWhite:0 alpha:0.55], nil]]; + _rightView.backgroundColor = [UIColor clearColor]; // set perspective of the transformation CATransform3D transform = CATransform3DIdentity; @@ -86,7 +88,7 @@ - (id)initWithFrame:(CGRect)frame foldDirection:(FoldDirection)foldDirection [_leftView.layer setTransform:CATransform3DMakeRotation((M_PI / 2), 0, 1, 0)]; [_rightView.layer setTransform:CATransform3DMakeRotation((M_PI / 2), 0, 1, 0)]; } - else if (self.foldDirection==FoldDirectionVertical) + else if (self.foldDirection==FoldDirectionVerticalBottomToTop || self.foldDirection == FoldDirectionVerticalTopToBottom) { // set anchor point of the leftView to the left edge _bottomView = [[FacingView alloc] initWithFrame:CGRectMake(0,3*frame.size.height/4,frame.size.width,frame.size.height/2) foldDirection:FoldDirectionVertical]; @@ -94,6 +96,7 @@ - (id)initWithFrame:(CGRect)frame foldDirection:(FoldDirection)foldDirection [_bottomView.layer setAnchorPoint:CGPointMake(0.5, 1.0)]; [self addSubview:_bottomView]; [_bottomView.shadowView setColorArrays:[NSArray arrayWithObjects:[UIColor colorWithWhite:0 alpha:0.05],[UIColor colorWithWhite:0 alpha:0.6], nil]]; + _bottomView.backgroundColor = [UIColor clearColor]; // set anchor point of the rightView to the right edge _topView = [[FacingView alloc] initWithFrame:CGRectMake(0,3*frame.size.height/4,frame.size.width,frame.size.height/2) foldDirection:FoldDirectionVertical]; @@ -101,6 +104,7 @@ - (id)initWithFrame:(CGRect)frame foldDirection:(FoldDirection)foldDirection [_topView.layer setAnchorPoint:CGPointMake(0.5, 0.0)]; [self addSubview:_topView]; [_topView.shadowView setColorArrays:[NSArray arrayWithObjects:[UIColor colorWithWhite:0 alpha:0.9],[UIColor colorWithWhite:0 alpha:0.55], nil]]; + _topView.backgroundColor = [UIColor clearColor]; // set perspective of the transformation CATransform3D transform = CATransform3DIdentity; @@ -119,6 +123,16 @@ - (id)initWithFrame:(CGRect)frame foldDirection:(FoldDirection)foldDirection return self; } +- (CGSize)realSize { + if (self.foldDirection == FoldDirectionHorizontalLeftToRight || self.foldDirection == FoldDirectionHorizontalRightToLeft) { + return CGSizeMake(self.leftView.frame.size.width + self.rightView.frame.size.width, self.frame.size.height); + } + else if (self.foldDirection == FoldDirectionVerticalBottomToTop || self.foldDirection == FoldDirectionVerticalTopToBottom) { + return CGSizeMake(self.frame.size.width, self.topView.frame.size.height + self.bottomView.frame.size.height); + } + return CGSizeZero; +} + - (void)unfoldViewToFraction:(CGFloat)fraction { if (self.foldDirection==FoldDirectionHorizontalRightToLeft || self.foldDirection==FoldDirectionHorizontalLeftToRight) @@ -140,7 +154,7 @@ - (void)unfoldViewToFraction:(CGFloat)fraction [self.leftView.shadowView setAlpha:1-fraction]; [self.rightView.shadowView setAlpha:1-fraction]; } - else if (self.foldDirection==FoldDirectionVertical) + else if (self.foldDirection==FoldDirectionVerticalBottomToTop || self.foldDirection == FoldDirectionVerticalTopToBottom) { float delta = asinf(fraction); @@ -172,7 +186,7 @@ - (void)calculateFoldStateFromOffset:(float)offset if (fraction < 0) fraction = 0; if (fraction > 1) fraction = 1; } - else if (self.foldDirection==FoldDirectionVertical) + else if (self.foldDirection==FoldDirectionVerticalBottomToTop || self.foldDirection == FoldDirectionVerticalTopToBottom) { fraction = offset / self.frame.size.height; if (fraction < 0) fraction = -1*fraction; @@ -218,13 +232,13 @@ - (void)unfoldWithParentOffset:(float)offset [self unfoldViewToFraction:fraction]; } - else if (self.foldDirection==FoldDirectionVertical) + else if (self.foldDirection==FoldDirectionVerticalBottomToTop || self.foldDirection == FoldDirectionVerticalTopToBottom) { fraction = offset / self.frame.size.height; if (fraction < 0) fraction = -1*fraction; if (fraction > 1) fraction = 1; + [self unfoldViewToFraction:fraction]; } - [self unfoldViewToFraction:fraction]; } - (void)setImage:(UIImage*)image @@ -240,7 +254,7 @@ - (void)setImage:(UIImage*)image [self.rightView.layer setContents:(__bridge id)imageRef2]; CFRelease(imageRef2); } - else if (self.foldDirection==FoldDirectionVertical) + else if (self.foldDirection==FoldDirectionVerticalBottomToTop || self.foldDirection == FoldDirectionVerticalTopToBottom) { CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], CGRectMake(0, image.size.height*image.scale/2, image.size.width*image.scale, image.size.height*image.scale/2)); [self.bottomView.layer setContents:(__bridge id)imageRef]; @@ -274,7 +288,7 @@ - (void)showFolds:(BOOL)show [self.leftView setHidden:!show]; [self.rightView setHidden:!show]; } - else if (self.foldDirection==FoldDirectionVertical) + else if (self.foldDirection==FoldDirectionVerticalBottomToTop || self.foldDirection == FoldDirectionVerticalTopToBottom) { [self.topView setHidden:!show]; [self.bottomView setHidden:!show]; diff --git a/PaperFold/PaperFold/PaperFold/MultiFoldView.h b/PaperFold/PaperFold/PaperFold/MultiFoldView.h index ade686f..0ce5061 100644 --- a/PaperFold/PaperFold/PaperFold/MultiFoldView.h +++ b/PaperFold/PaperFold/PaperFold/MultiFoldView.h @@ -1,44 +1,14 @@ -/** - * Copyright (c) 2012 Muh Hon Cheng - * Created by honcheng on 6/2/12. - * - * 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. - * - * @author Muh Hon Cheng - * @copyright 2012 Muh Hon Cheng - * @version - * - */ +// +// MultiFoldView.h +// PaperFold +// +// Created by Wang Hailong on 12-12-19. +// Copyright (c) 2012年 honcheng@gmail.com. All rights reserved. +// -@class MKMapView; #import #import "FoldView.h" -@protocol MultiFoldViewDelegate -- (CGFloat)displacementOfMultiFoldView:(id)multiFoldView; -@end - @interface MultiFoldView : UIView // number of folds @property (nonatomic, assign) int numberOfFolds; @@ -52,13 +22,10 @@ // optimized screenshot follows the scale of the screen // non-optimized is always the non-retina image @property (nonatomic, assign) BOOL useOptimizedScreenshot; -// take screenshot just before unfolding -// this is only necessary for mapview, not for the rest of the views -@property (nonatomic, readonly) BOOL shouldTakeScreenshotBeforeUnfolding; @property (nonatomic, strong) UIView *contentViewHolder; -@property (nonatomic, assign) id delegate; +@property (nonatomic, readonly, assign) float offset; // init with the number of folds and pull factor @@ -68,14 +35,10 @@ // set the content of the view - (void)setContent:(UIView *)contentView; -// get screenshot of content to overlay in folds -- (void)drawScreenshotOnFolds; - (void)setScreenshotImage:(UIImage*)image; -// set fold states based on offset value -- (void)calculateFoldStateFromOffset:(float)offset; - // unfold the based on parent offset +// offset MUST BE a positive number - (void)unfoldWithParentOffset:(float)offset; // unfold using a fraction 0 to 1 @@ -84,9 +47,6 @@ // fraction is calculated based on parent offset - (void)unfoldViewToFraction:(CGFloat)fraction; -// unfold foldView using fraction -- (void)unfoldView:(FoldView*)foldView toFraction:(CGFloat)fraction withOffset:(float)offset; - // show/hide all folds - (void)showFolds:(BOOL)show; @@ -94,11 +54,4 @@ // temporary method - (void)unfoldWithoutAnimation; -#pragma mark states -// states of folds -- (void)foldDidOpened; -- (void)foldDidClosed; -- (void)foldWillOpen; -- (void)foldWillClose; - @end diff --git a/PaperFold/PaperFold/PaperFold/MultiFoldView.m b/PaperFold/PaperFold/PaperFold/MultiFoldView.m index 4286da9..84ac0a3 100644 --- a/PaperFold/PaperFold/PaperFold/MultiFoldView.m +++ b/PaperFold/PaperFold/PaperFold/MultiFoldView.m @@ -1,49 +1,34 @@ -/** - * Copyright (c) 2012 Muh Hon Cheng - * Created by honcheng on 6/2/12. - * - * 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. - * - * @author Muh Hon Cheng - * @copyright 2012 Muh Hon Cheng - * @version - * - */ - +// +// MultiFoldView.m +// PaperFold +// +// Created by Wang Hailong on 12-12-19. +// Copyright (c) 2012年 honcheng@gmail.com. All rights reserved. +// #import "MultiFoldView.h" + #import "UIView+Screenshot.h" #import +@interface MultiFoldView () + +// take screenshot just before unfolding +// this is only necessary for mapview, not for the rest of the views +@property (nonatomic, readonly) BOOL shouldTakeScreenshotBeforeUnfolding; + +@end + @implementation MultiFoldView + #define FOLDVIEW_TAG 1000 - (id)initWithFrame:(CGRect)frame foldDirection:(FoldDirection)foldDirection folds:(int)folds pullFactor:(float)factor { self = [super initWithFrame:frame]; if (self) { + self.backgroundColor = [UIColor clearColor]; _useOptimizedScreenshot = YES; _foldDirection = foldDirection; @@ -54,7 +39,7 @@ - (id)initWithFrame:(CGRect)frame foldDirection:(FoldDirection)foldDirection fol _pullFactor = 0; } else _pullFactor = factor; - + // create multiple FoldView next to each other for (int i=0; i<_numberOfFolds; i++) { @@ -62,17 +47,18 @@ - (id)initWithFrame:(CGRect)frame foldDirection:(FoldDirection)foldDirection fol { float foldWidth = frame.size.width/self.numberOfFolds; FoldView *foldView = [[FoldView alloc] initWithFrame:CGRectMake(foldWidth*i,0,foldWidth,frame.size.height) foldDirection:foldDirection]; - [foldView setTag:FOLDVIEW_TAG+i]; + [foldView setTag:FOLDVIEW_TAG + i]; [self addSubview:foldView]; } - else if (_foldDirection==FoldDirectionVertical) + else if (_foldDirection==FoldDirectionVerticalTopToBottom || _foldDirection==FoldDirectionVerticalBottomToTop) { float foldHeight = frame.size.height/self.numberOfFolds; - FoldView *foldView = [[FoldView alloc] initWithFrame:CGRectMake(0,foldHeight*(self.numberOfFolds-i)-foldHeight,frame.size.width,foldHeight) foldDirection:foldDirection]; + FoldView *foldView = [[FoldView alloc] initWithFrame:CGRectMake(0,foldHeight*i,frame.size.width,foldHeight) foldDirection:foldDirection]; [foldView setTag:FOLDVIEW_TAG+i]; [self addSubview:foldView]; } } + [self showFolds:NO]; [self setAutoresizesSubviews:YES]; } return self; @@ -98,25 +84,14 @@ - (void)setContent:(UIView *)contentView // if content view is a map view, screenshot will be a blank grid [self drawScreenshotOnFolds]; [self.contentViewHolder setHidden:YES]; - -// // set the content view -// self.contentView = contentView; -// [self.contentView setFrame:CGRectMake(0,0,contentView.frame.size.width,contentView.frame.size.height)]; -// [self.contentView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleWidth]; -// // place content view below folds -// [self insertSubview:self.contentView atIndex:0]; -// // immediately take a screenshot of the content view to overlay in fold -// // if content view is a map view, screenshot will be a blank grid -// [self drawScreenshotOnFolds]; -// [self.contentView setHidden:YES]; } +// get screenshot of content to overlay in folds - (void)drawScreenshotOnFolds { UIImage *image = [self.contentViewHolder screenshotWithOptimization:self.useOptimizedScreenshot]; [self setScreenshotImage:image]; // get screenshot of content view, and splice the image to overlay in different folds - } - (void)setScreenshotImage:(UIImage*)image @@ -143,7 +118,7 @@ - (void)setScreenshotImage:(UIImage*)image } } - else if (self.foldDirection==FoldDirectionVertical) + else if (self.foldDirection==FoldDirectionVerticalTopToBottom || self.foldDirection==FoldDirectionVerticalBottomToTop) { float foldHeight = image.size.height/self.numberOfFolds; for (int i=0; i0) { _state = FoldStateTransition; @@ -201,213 +179,114 @@ - (void)calculateFoldStateFromOffset:(float)offset } } -// use the parent offset to calculate fraction +- (void)unfoldViewToFraction:(CGFloat)fraction { + if (self.foldDirection == FoldDirectionHorizontalLeftToRight || self.foldDirection == FoldDirectionHorizontalRightToLeft) { + [self unfoldWithParentOffset:fraction * self.frame.size.width]; + } + else if (self.foldDirection == FoldDirectionVerticalBottomToTop || self.foldDirection == FoldDirectionVerticalTopToBottom) { + [self unfoldWithParentOffset:fraction * self.frame.size.height]; + } +} + - (void)unfoldWithParentOffset:(float)offset { + // start the cascading effect of unfolding + // with the first foldView with index FOLDVIEW_TAG+0 + if (offset < 0) { + NSLog(@"Error! %s offset MUST BE a Positive Number %f",__func__, offset); + offset = -offset; + } + _offset = offset; [self calculateFoldStateFromOffset:offset]; + if (self.foldDirection == FoldDirectionHorizontalLeftToRight) { + [self unfoldLeftToRightViewWithParentOffset:offset]; + } else if (self.foldDirection == FoldDirectionHorizontalRightToLeft) { + [self unfoldRightToLeftViewWithParentOffset:offset]; + } else if (self.foldDirection == FoldDirectionVerticalTopToBottom) { + [self unfoldTopToBottomViewWithParentOffset:offset]; + } else if (self.foldDirection == FoldDirectionVerticalBottomToTop) { + [self unfoldBottomToTopViewWithParentOffset:offset]; + } +} + +- (void)unfoldLeftToRightViewWithParentOffset:(float)offset { + float foldWidth = self.frame.size.width/self.numberOfFolds; + CGFloat fraction; - if (self.foldDirection==FoldDirectionHorizontalRightToLeft || self.foldDirection==FoldDirectionHorizontalLeftToRight) - { - float foldWidth = self.frame.size.width/self.numberOfFolds; - CGFloat fraction; - if (offset < 0) { - if (offset<-1*(foldWidth+self.pullFactor*foldWidth)) - { - offset = -1*(foldWidth+self.pullFactor*foldWidth); - } - fraction = offset /(-1*(foldWidth+self.pullFactor*foldWidth)); + float foldOffSet = offset; + for (int index = 0; index < self.numberOfFolds; index ++) { + if (index == self.numberOfFolds - 1) { + fraction = foldOffSet / foldWidth; } else { - if (offset > (foldWidth+self.pullFactor*foldWidth)) - { - offset = (foldWidth+self.pullFactor*foldWidth); - } - fraction = offset /(foldWidth+self.pullFactor*foldWidth); + fraction = foldOffSet / (foldWidth + self.pullFactor * foldWidth); } - //fraction = offset /(-1*(foldWidth+self.pullFactor*foldWidth)); + if (fraction > 1) fraction = 1; // This make sure fraction must <= 1 - if (fraction < 0) fraction = -1*fraction;//0; - if (fraction > 1) fraction = 1; - [self unfoldViewToFraction:fraction]; - } - else if (self.foldDirection==FoldDirectionVertical) - { - float foldHeight = self.frame.size.height/self.numberOfFolds; - - if (offset>(foldHeight+self.pullFactor*foldHeight)) - { - offset = (foldHeight+self.pullFactor*foldHeight); - } - - CGFloat fraction = offset /(foldHeight+self.pullFactor*foldHeight); - if (fraction < 0) fraction = -1*fraction;//0; - if (fraction > 1) fraction = 1; - - [self unfoldViewToFraction:fraction]; + FoldView *foldView = (FoldView*)[self viewWithTag:FOLDVIEW_TAG + index]; + [foldView unfoldViewToFraction:fraction]; + [foldView setFrame:CGRectMake(foldOffSet - [foldView realSize].width, 0, foldView.frame.size.width, foldView.frame.size.height)]; + foldOffSet = foldView.frame.origin.x; } } -- (void)unfoldViewToFraction:(CGFloat)fraction -{ - // start the cascading effect of unfolding - // with the first foldView with index FOLDVIEW_TAG+0 - FoldView *firstFoldView = (FoldView*)[self viewWithTag:FOLDVIEW_TAG]; +- (void)unfoldRightToLeftViewWithParentOffset:(float)offset { + float foldWidth = self.frame.size.width/self.numberOfFolds; + CGFloat fraction; - if (self.foldDirection==FoldDirectionHorizontalLeftToRight) - { - float offset = 0.0; - if ([self.delegate respondsToSelector:@selector(displacementOfMultiFoldView:)]) - { - offset = [self.delegate displacementOfMultiFoldView:self]; - } - else - { - offset = self.superview.frame.origin.x; + float foldOffSet = 0; + for (int index = 0; index < self.numberOfFolds; index ++) { + if (index == self.numberOfFolds - 1) { + fraction = (offset - foldOffSet) / foldWidth; + } else { + fraction = (offset - foldOffSet) / (foldWidth + self.pullFactor * foldWidth); } - if (offset<0) offset = -1*offset; - [self unfoldView:firstFoldView toFraction:fraction withOffset:offset]; + if (fraction > 1) fraction = 1; // This make sure fraction must <= 1 + + FoldView *foldView = (FoldView*)[self viewWithTag:FOLDVIEW_TAG + index]; + [foldView unfoldViewToFraction:fraction]; + [foldView setFrame:CGRectMake(foldOffSet, 0, foldView.frame.size.width, foldView.frame.size.height)]; + foldOffSet = foldView.frame.origin.x + [foldView realSize].width; } - else [self unfoldView:firstFoldView toFraction:fraction withOffset:0]; } -- (void)unfoldView:(FoldView*)foldView toFraction:(CGFloat)fraction withOffset:(float)offset -{ - // unfold the subfold - [foldView unfoldViewToFraction:fraction]; +- (void)unfoldTopToBottomViewWithParentOffset:(float)offset { + float foldHeight = self.frame.size.height/self.numberOfFolds; + CGFloat fraction; - if (self.foldDirection==FoldDirectionHorizontalLeftToRight || self.foldDirection==FoldDirectionHorizontalRightToLeft) - { - if (self.foldDirection==FoldDirectionHorizontalLeftToRight) { - [foldView setFrame:CGRectMake(offset - 2*foldView.rightView.frame.size.width, 0, foldView.frame.size.width, foldView.frame.size.height)]; - + float foldOffSet = 0; + for (int index = 0; index < self.numberOfFolds; index ++) { + if (index == self.numberOfFolds - 1) { + fraction = (offset - foldOffSet) / foldHeight; + } else { + fraction = (offset - foldOffSet) / (foldHeight + self.pullFactor * foldHeight); } + if (fraction > 1) fraction = 1; // This make sure fraction must <= 1 - // check if there is another subfold beside this fold - int index = [foldView tag] - FOLDVIEW_TAG; - if (index < self.numberOfFolds-1) - { - FoldView *nextFoldView = (FoldView*)[self viewWithTag:FOLDVIEW_TAG+index+1]; - // set the origin of the next foldView - // set the origin of the next foldView - if (self.foldDirection==FoldDirectionHorizontalLeftToRight) { - [nextFoldView setFrame:CGRectMake(foldView.frame.origin.x - 2*nextFoldView.rightView.frame.size.width,0,nextFoldView.frame.size.width,nextFoldView.frame.size.height)]; - } else { - [nextFoldView setFrame:CGRectMake(foldView.frame.origin.x + 2*foldView.leftView.frame.size.width,0,nextFoldView.frame.size.width,nextFoldView.frame.size.height)]; - } - - float foldWidth = self.frame.size.width/self.numberOfFolds; - // calculate the offset between the right edge of the last subfold, and the edge of the screen - // use this offset to readjust the fraction - float displacement = 0.0; - if ([self.delegate respondsToSelector:@selector(displacementOfMultiFoldView:)]) - { - displacement = [self.delegate displacementOfMultiFoldView:self]; - } - else - { - displacement = self.superview.frame.origin.x; - } - - float x; - if (self.foldDirection==FoldDirectionHorizontalLeftToRight) { - //x = (foldView.frame.origin.x + (fraction * foldView.frame.size.width)) - 2*foldView.rightView.frame.size.width; - x = (foldView.frame.origin.x + (fraction * foldView.frame.size.width)) - 2*foldView.rightView.frame.size.width; - //x = displacement - x; - - } else{ - x = displacement+foldView.frame.origin.x+2*foldView.leftView.frame.size.width; - //x = self.superview.frame.origin.x+foldView.frame.origin.x+2*foldView.leftView.frame.size.width; - } - - //float x = self.superview.frame.origin.x+foldView.frame.origin.x+2*foldView.leftView.frame.size.width; - CGFloat adjustedFraction = 0; - if (self.foldDirection==FoldDirectionHorizontalLeftToRight) { - x = -x; - } - if (index+1==self.numberOfFolds-1) - { - // if this is the last fold, do not use the pull factor - // so that the right edge of this subfold aligns with the right edge of the screen - adjustedFraction = (-1*x)/(foldWidth); - } - else - { - // if this is not the last fold, use the pull factor - adjustedFraction = (-1*x)/(foldWidth+self.pullFactor*foldWidth); - } - if (adjustedFraction < 0) adjustedFraction = 0; - if (adjustedFraction > 1) adjustedFraction = 1; - - // unfold this foldView with the fraction - // by calling the same function - // this drills in to the next subfold in a cascading effect depending on the number of available folds - - //[self unfoldView:nextFoldView toFraction:adjustedFraction]; - //NSLog(@"%@ %f", foldView, foldView.frame.origin.x); - [self unfoldView:nextFoldView toFraction:adjustedFraction withOffset:foldView.frame.origin.x]; - } - } - else if (self.foldDirection==FoldDirectionVertical) - { - // check if there is another subfold beside this fold - int index = [foldView tag] - FOLDVIEW_TAG; + FoldView *foldView = (FoldView*)[self viewWithTag:FOLDVIEW_TAG + index]; + [foldView unfoldViewToFraction:fraction]; + [foldView setFrame:CGRectMake(0, self.frame.size.height - foldOffSet - foldView.frame.size.height, foldView.frame.size.width, foldView.frame.size.height)]; - if (index < self.numberOfFolds-1) - { - FoldView *nextFoldView = (FoldView*)[self viewWithTag:FOLDVIEW_TAG+index+1]; - // set the origin of the next foldView - [nextFoldView setFrame:CGRectMake(0,foldView.frame.origin.y - 2*foldView.bottomView.frame.size.height,nextFoldView.frame.size.width,nextFoldView.frame.size.height)]; - - float foldHeight = self.frame.size.height/self.numberOfFolds; - // calculate the offset between the right edge of the last subfold, and the edge of the screen - // use this offset to readjust the fraction - float displacement = 0.0; - if ([self.delegate respondsToSelector:@selector(displacementOfMultiFoldView:)]) - { - displacement = [self.delegate displacementOfMultiFoldView:self]; - } - else - { - if ([self.superview isKindOfClass:[UIScrollView class]]) - { - displacement = -1*[(UIScrollView*)self.superview contentOffset].y; - } - else - { - displacement = self.superview.frame.origin.y ; - } - } - float y = displacement - 2*foldView.bottomView.frame.size.height; - int _index = index - 1; - while (_index>=0) - { - FoldView *prevFoldView = (FoldView*)[self viewWithTag:FOLDVIEW_TAG+_index]; - y -= 2*prevFoldView.bottomView.frame.size.height; - _index -= 1; - } - - CGFloat adjustedFraction = 0; - if (index+1==self.numberOfFolds-1) - { - // if this is the last fold, do not use the pull factor - // so that the right edge of this subfold aligns with the right edge of the screen - adjustedFraction = y/(foldHeight); - } - else - { - // if this is not the last fold, use the pull factor - adjustedFraction = y/(foldHeight+self.pullFactor*foldHeight); - } + foldOffSet += [foldView realSize].height; + } +} - if (adjustedFraction < 0) adjustedFraction = 0; - if (adjustedFraction > 1) adjustedFraction = 1; - // unfold this foldView with the fraction - // by calling the same function - - // this drills in to the next subfold in a cascading effect depending on the number of available folds - [self unfoldView:nextFoldView toFraction:adjustedFraction withOffset:0]; +- (void)unfoldBottomToTopViewWithParentOffset:(float)offset { + float foldHeight = self.frame.size.height/self.numberOfFolds; + CGFloat fraction; + float foldOffSet = offset; + for (int index = 0; index < self.numberOfFolds; index ++) { + if (index == self.numberOfFolds - 1) { + fraction = foldOffSet / foldHeight; + } else { + fraction = foldOffSet / (foldHeight + self.pullFactor * foldHeight); } + if (fraction > 1) fraction = 1; // This make sure fraction must <= 1 + + FoldView *foldView = (FoldView*)[self viewWithTag:FOLDVIEW_TAG + index]; + [foldView unfoldViewToFraction:fraction]; + [foldView setFrame:CGRectMake(0, self.frame.size.height - foldOffSet - (foldView.frame.size.height - [foldView realSize].height), foldView.frame.size.width, foldView.frame.size.height)]; + foldOffSet -= [foldView realSize].height; } - } // hide fold (when content view is visible) and show fold (when content view is hidden @@ -439,7 +318,7 @@ - (void)foldDidOpened - (void)foldDidClosed { [self.contentViewHolder setHidden:YES]; - [self showFolds:YES]; + [self showFolds:NO]; } // when fold is about to be opened, make sure content view is hidden, and show fold @@ -462,6 +341,4 @@ - (void)foldWillClose [self showFolds:YES]; } - - @end diff --git a/PaperFold/PaperFold/PaperFold/PaperFoldConstants.h b/PaperFold/PaperFold/PaperFold/PaperFoldConstants.h index 7ef0f85..4fadde6 100644 --- a/PaperFold/PaperFold/PaperFold/PaperFoldConstants.h +++ b/PaperFold/PaperFold/PaperFold/PaperFoldConstants.h @@ -27,7 +27,9 @@ typedef enum { FoldDirectionHorizontalRightToLeft = 0, FoldDirectionHorizontalLeftToRight = 1, - FoldDirectionVertical = 2, + FoldDirectionVertical = 2, // Compatible previous version + FoldDirectionVerticalTopToBottom = FoldDirectionVertical, + FoldDirectionVerticalBottomToTop = 3, } FoldDirection; typedef enum diff --git a/PaperFold/PaperFold/PaperFold/PaperFoldView.h b/PaperFold/PaperFold/PaperFold/PaperFoldView.h index f46b2e9..7f7552d 100644 --- a/PaperFold/PaperFold/PaperFold/PaperFoldView.h +++ b/PaperFold/PaperFold/PaperFold/PaperFoldView.h @@ -49,7 +49,7 @@ typedef void (^CompletionBlock)(); - (void)paperFoldView:(id)paperFoldView viewDidOffset:(CGPoint)offset; @end -@interface PaperFoldView : UIView +@interface PaperFoldView : UIView < UIGestureRecognizerDelegate> // main content view @property (nonatomic, strong) TouchThroughUIView *contentView; @@ -57,7 +57,7 @@ typedef void (^CompletionBlock)(); // manual animation with NSTimer is required to sync the offset of the contentView, with the folding of views @property (nonatomic, strong) NSTimer *animationTimer; // the fold view on the left and bottom -@property (nonatomic, strong) FoldView *bottomFoldView; +@property (nonatomic, strong) MultiFoldView *bottomFoldView; // the fold view on the left @property (nonatomic, strong) MultiFoldView *leftFoldView; // the multiple fold view on the right diff --git a/PaperFold/PaperFold/PaperFold/PaperFoldView.m b/PaperFold/PaperFold/PaperFold/PaperFoldView.m index 75699b7..c599018 100644 --- a/PaperFold/PaperFold/PaperFold/PaperFoldView.m +++ b/PaperFold/PaperFold/PaperFold/PaperFoldView.m @@ -123,7 +123,6 @@ - (void)setLeftFoldContentView:(UIView*)view foldCount:(int)leftViewFoldCount pu { if (self.leftFoldView) [self.leftFoldView removeFromSuperview]; self.leftFoldView = [[MultiFoldView alloc] initWithFrame:CGRectMake(0,0,view.frame.size.width,self.frame.size.height) foldDirection:FoldDirectionHorizontalLeftToRight folds:leftViewFoldCount pullFactor:leftViewPullFactor]; - [self.leftFoldView setDelegate:self]; [self.leftFoldView setUseOptimizedScreenshot:self.useOptimizedScreenshot]; [self.leftFoldView setAutoresizingMask:UIViewAutoresizingFlexibleHeight]; [self insertSubview:self.leftFoldView belowSubview:self.contentView]; @@ -147,13 +146,16 @@ - (void)setBottomFoldContentView:(UIView*)view { if (self.bottomFoldView) [self.bottomFoldView removeFromSuperview]; - self.bottomFoldView = [[FoldView alloc] initWithFrame:CGRectMake(0,self.frame.size.height-view.frame.size.height,view.frame.size.width,view.frame.size.height) foldDirection:FoldDirectionVertical]; + // self.bottomFoldView = [[FoldView alloc] initWithFrame:CGRectMake(0,self.frame.size.height-view.frame.size.height,view.frame.size.width,view.frame.size.height) foldDirection:FoldDirectionVertical]; + self.bottomFoldView = [[MultiFoldView alloc] initWithFrame:CGRectMake(0,self.frame.size.height-view.frame.size.height,view.frame.size.width,view.frame.size.height) foldDirection:FoldDirectionVerticalBottomToTop folds:5 pullFactor:0.9]; +// [self.bottomFoldView setDelegate:self]; [self.bottomFoldView setUseOptimizedScreenshot:self.useOptimizedScreenshot]; [self.bottomFoldView setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; [self insertSubview:self.bottomFoldView belowSubview:self.contentView]; [self.bottomFoldView setContent:view]; [self.bottomFoldView setHidden:YES]; [view setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; + [view setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth]; UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0,self.frame.size.height,self.frame.size.width,1)]; [line setAutoresizingMask:UIViewAutoresizingFlexibleHeight]; @@ -168,7 +170,7 @@ - (void)setBottomFoldContentView:(UIView*)view - (void)setRightFoldContentView:(UIView*)view foldCount:(int)rightViewFoldCount pullFactor:(float)rightViewPullFactor { self.rightFoldView = [[MultiFoldView alloc] initWithFrame:CGRectMake(self.frame.size.width,0,view.frame.size.width,self.frame.size.height) foldDirection:FoldDirectionHorizontalRightToLeft folds:rightViewFoldCount pullFactor:rightViewPullFactor]; - [self.rightFoldView setDelegate:self]; + [self.rightFoldView setUseOptimizedScreenshot:self.useOptimizedScreenshot]; [self.rightFoldView setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleHeight]; [self.contentView insertSubview:self.rightFoldView atIndex:0]; @@ -195,8 +197,8 @@ - (void)setRightFoldContentView:(UIView*)view rightViewFoldCount:(int)rightViewF - (void)setTopFoldContentView:(UIView*)view topViewFoldCount:(int)topViewFoldCount topViewPullFactor:(float)topViewPullFactor { - self.topFoldView = [[MultiFoldView alloc] initWithFrame:CGRectMake(0,-1*view.frame.size.height,view.frame.size.width,view.frame.size.height) foldDirection:FoldDirectionVertical folds:topViewFoldCount pullFactor:topViewPullFactor]; - [self.topFoldView setDelegate:self]; + self.topFoldView = [[MultiFoldView alloc] initWithFrame:CGRectMake(0,-1*view.frame.size.height,view.frame.size.width,view.frame.size.height) foldDirection:FoldDirectionVerticalTopToBottom folds:topViewFoldCount pullFactor:topViewPullFactor]; + [self.topFoldView setUseOptimizedScreenshot:self.useOptimizedScreenshot]; [self.topFoldView setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleHeight]; [self.contentView insertSubview:self.topFoldView atIndex:0]; @@ -219,12 +221,12 @@ - (void)onContentViewPanned:(UIPanGestureRecognizer*)gesture { // cancel gesture if another animation has not finished yet if ([self.animationTimer isValid]) return; - + if ([gesture state]==UIGestureRecognizerStateBegan) { // show the divider while dragging [self setShowDividerLines:YES animated:YES]; - + CGPoint velocity = [gesture velocityInView:self]; if ( abs(velocity.x) > abs(velocity.y)) { @@ -331,7 +333,7 @@ - (void)onContentViewPannedVertically:(UIPanGestureRecognizer*)gesture //[self setPaperFoldState:PaperFoldStateDefault]; self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(restoreView:) userInfo:nil repeats:YES]; - + } } @@ -341,7 +343,7 @@ - (void)onContentViewPannedHorizontally:(UIPanGestureRecognizer*)gesture [self.leftFoldView setHidden:NO]; [self.bottomFoldView setHidden:YES]; [self.topFoldView setHidden:YES]; - + CGPoint point = [gesture translationInView:self]; if ([gesture state]==UIGestureRecognizerStateChanged) { @@ -449,7 +451,7 @@ - (void)animateWithContentOffset:(CGPoint)point panned:(BOOL)panned x1 = -self.rightFoldView.frame.size.width; } [self.contentView setTransform:CGAffineTransformMakeTranslation(x1, 0)]; - [self.rightFoldView unfoldWithParentOffset:x]; + [self.rightFoldView unfoldWithParentOffset:-x]; if ([self.delegate respondsToSelector:@selector(paperFoldView:viewDidOffset:)]) { @@ -490,7 +492,7 @@ - (void)animateWithContentOffset:(CGPoint)point panned:(BOOL)panned y = -self.bottomFoldView.frame.size.height; } [self.contentView setTransform:CGAffineTransformMakeTranslation(0, y)]; - [self.bottomFoldView unfoldWithParentOffset:y]; + [self.bottomFoldView unfoldWithParentOffset:-y]; if ([self.delegate respondsToSelector:@selector(paperFoldView:viewDidOffset:)]) { @@ -548,18 +550,18 @@ - (void)unfoldBottomView:(NSTimer*)timer float y = transform.ty - (self.bottomFoldView.frame.size.height+transform.ty)/4; transform = CGAffineTransformMakeTranslation(0, y); [self.contentView setTransform:transform]; - + if (-y>=self.bottomFoldView.frame.size.height-2) { [timer invalidate]; transform = CGAffineTransformMakeTranslation(0,-1*self.bottomFoldView.frame.size.height); [self.contentView setTransform:transform]; - + if (self.lastState != PaperFoldStateBottomUnfolded) { [self finishForState:PaperFoldStateBottomUnfolded]; } } - + // use the x value to animate folding [self animateWithContentOffset:CGPointMake(0, self.contentView.frame.origin.y) panned:NO]; } @@ -605,7 +607,7 @@ - (void)unfoldTopView:(NSTimer*)timer float y = transform.ty + (self.topFoldView.frame.size.height-transform.ty)/8; transform = CGAffineTransformMakeTranslation(0, y); [self.contentView setTransform:transform]; - + if (y>=self.topFoldView.frame.size.height-5) { [timer invalidate]; @@ -633,7 +635,7 @@ - (void)unfoldRightView:(NSTimer*)timer float x = transform.tx - (transform.tx+self.rightFoldView.frame.size.width)/8; transform = CGAffineTransformMakeTranslation(x, 0); [self.contentView setTransform:transform]; - + if (x<=-self.rightFoldView.frame.size.width+5) { [timer invalidate]; @@ -781,8 +783,8 @@ - (void)setPaperFoldState:(PaperFoldState)state } - (void)setPaperFoldState:(PaperFoldState)state - animated:(BOOL)animated - completion:(void (^)())completion + animated:(BOOL)animated + completion:(void (^)())completion { self.completionBlock = completion; [self setPaperFoldState:state animated:animated]; @@ -834,11 +836,11 @@ - (void)setShowDividerLines:(BOOL)showDividerLines animated:(BOOL)animated { if (_showDividerLines == showDividerLines) return; - + _showDividerLines = showDividerLines; CGFloat alpha = showDividerLines ? 1 : 0; [UIView animateWithDuration:animated ? 0.25 : 0 - animations: + animations: ^{ self.leftDividerLine.alpha = alpha; self.topDividerLine.alpha = alpha; diff --git a/PaperFold/PaperFold/PaperFold/Resources/miao.png b/PaperFold/PaperFold/PaperFold/Resources/miao.png new file mode 100644 index 0000000..8b74d26 Binary files /dev/null and b/PaperFold/PaperFold/PaperFold/Resources/miao.png differ diff --git a/PaperFold/PaperFold/PaperFold/ShadowView.m b/PaperFold/PaperFold/PaperFold/ShadowView.m index a7a66a4..bcbe3fc 100755 --- a/PaperFold/PaperFold/PaperFold/ShadowView.m +++ b/PaperFold/PaperFold/PaperFold/ShadowView.m @@ -44,7 +44,7 @@ - (id)initWithFrame:(CGRect)frame foldDirection:(FoldDirection)foldDirection _gradient = [CAGradientLayer layer]; [_gradient setFrame:CGRectMake(0,0,frame.size.width,frame.size.height)]; - if (foldDirection==FoldDirectionVertical) + if (foldDirection == FoldDirectionVerticalBottomToTop || foldDirection == FoldDirectionVerticalTopToBottom) { [_gradient setStartPoint:CGPointMake(0, 1)]; [_gradient setEndPoint:CGPointMake(0, 0)]; diff --git a/PaperFold/PaperFold/PaperFold/SinglePaperFoldView.h b/PaperFold/PaperFold/PaperFold/SinglePaperFoldView.h new file mode 100644 index 0000000..13ad24b --- /dev/null +++ b/PaperFold/PaperFold/PaperFold/SinglePaperFoldView.h @@ -0,0 +1,27 @@ +// +// SinglePaperFoldView.h +// PaperFold +// +// Created by Wang Hailong on 12-12-19. +// Copyright (c) 2012年 honcheng@gmail.com. All rights reserved. +// + +#import +#import "MultiFoldView.h" + +@interface SinglePaperFoldView : UIView + +- (id)initWithFrame:(CGRect)frame foldDirection:(FoldDirection)foldDirection folds:(int)folds pullFactor:(float)factor; + +#pragma mark Getter & Setter +- (void)setContent:(UIView *)contentView; + +#pragma mark Unfold & fold +- (void)unfoldWithParentOffset:(float)offset; +- (void)unfoldViewToFraction:(CGFloat)fraction; + +- (void)unfoldPaper:(BOOL)unfold Animation:(BOOL)animation; + +- (FoldState)foldState; + +@end diff --git a/PaperFold/PaperFold/PaperFold/SinglePaperFoldView.m b/PaperFold/PaperFold/PaperFold/SinglePaperFoldView.m new file mode 100644 index 0000000..199652d --- /dev/null +++ b/PaperFold/PaperFold/PaperFold/SinglePaperFoldView.m @@ -0,0 +1,122 @@ +// +// SinglePaperFoldView.m +// PaperFold +// +// Created by Wang Hailong on 12-12-19. +// Copyright (c) 2012年 honcheng@gmail.com. All rights reserved. +// + +#import "SinglePaperFoldView.h" + +@interface SinglePaperFoldView () + +@property (nonatomic, strong) MultiFoldView *multiFoldView; +@property (nonatomic, strong) NSTimer *animationTimer; + +@end + +@implementation SinglePaperFoldView + +- (id)initWithFrame:(CGRect)frame foldDirection:(FoldDirection)foldDirection folds:(int)folds pullFactor:(float)factor { + self = [super initWithFrame:frame]; + if (self) { + self.backgroundColor = [UIColor clearColor]; + _multiFoldView = [[MultiFoldView alloc] initWithFrame:self.bounds foldDirection:foldDirection folds:folds pullFactor:factor]; + [self addSubview:_multiFoldView]; + } + return self; +} + +- (void)setContent:(UIView *)contentView { + [self.multiFoldView setContent:contentView]; +} + +#pragma mark Unfold & fold +- (void)unfoldWithParentOffset:(float)offset { + [self.multiFoldView unfoldWithParentOffset:offset]; +} + +- (void)unfoldViewToFraction:(CGFloat)fraction { + [self.multiFoldView unfoldViewToFraction:fraction]; +} + +- (void)unfoldWithoutAnimation { + [self.multiFoldView unfoldWithoutAnimation]; +} + +- (void)unfoldPaper:(BOOL)unfold Animation:(BOOL)animation { + if (animation) { + if (unfold) { + [self.animationTimer invalidate]; + self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(unfoldView:) userInfo:nil repeats:YES]; + } + else { + [self.animationTimer invalidate]; + self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(restoreView:) userInfo:nil repeats:YES]; + } + } + else { + if (unfold) { + [self unfoldWithoutAnimation]; + } + else { + [self.multiFoldView unfoldViewToFraction:0]; + } + } +} + +- (void)unfoldView:(NSTimer*)timer { + if (self.multiFoldView.foldDirection == FoldDirectionHorizontalLeftToRight || self.multiFoldView.foldDirection == FoldDirectionHorizontalRightToLeft) { + float x = self.multiFoldView.offset + (self.multiFoldView.frame.size.width - self.multiFoldView.offset) / 8; + if (x > self.multiFoldView.frame.size.width - 3) { + [timer invalidate]; + x = self.multiFoldView.frame.size.width; + } + [self.multiFoldView unfoldWithParentOffset:x]; + if (self.multiFoldView.foldDirection == FoldDirectionHorizontalRightToLeft) { + [self.multiFoldView setTransform:CGAffineTransformMakeTranslation(self.multiFoldView.frame.size.width - self.multiFoldView.offset, 0)]; + } + } + else if (self.multiFoldView.foldDirection == FoldDirectionVerticalBottomToTop || self.multiFoldView.foldDirection == FoldDirectionVerticalTopToBottom) { + float y = self.multiFoldView.offset + (self.multiFoldView.frame.size.height - self.multiFoldView.offset) / 8; + if (y > self.multiFoldView.frame.size.height - 3) { + [timer invalidate]; + y = self.multiFoldView.frame.size.height; + } + [self.multiFoldView unfoldWithParentOffset:y]; + if (self.multiFoldView.foldDirection == FoldDirectionVerticalTopToBottom) { + [self.multiFoldView setTransform:CGAffineTransformMakeTranslation(0, - (self.multiFoldView.frame.size.height - self.multiFoldView.offset))]; + } + } +} + +- (void)restoreView:(NSTimer *)timer { + if (self.multiFoldView.foldDirection == FoldDirectionHorizontalLeftToRight || self.multiFoldView.foldDirection == FoldDirectionHorizontalRightToLeft) { + float x = self.multiFoldView.offset - self.multiFoldView.offset / 8; + if (x < 3) { + [timer invalidate]; + x = 0; + } + [self.multiFoldView unfoldWithParentOffset:x]; + if (self.multiFoldView.foldDirection == FoldDirectionHorizontalRightToLeft) { + [self.multiFoldView setTransform:CGAffineTransformMakeTranslation(self.multiFoldView.frame.size.width - self.multiFoldView.offset, 0)]; + } + } + else if (self.multiFoldView.foldDirection == FoldDirectionVerticalBottomToTop || self.multiFoldView.foldDirection == FoldDirectionVerticalTopToBottom) { + float y = self.multiFoldView.offset - self.multiFoldView.offset / 8; + if (y < 3) { + [timer invalidate]; + y = 0; + } + [self.multiFoldView unfoldWithParentOffset:y]; + if (self.multiFoldView.foldDirection == FoldDirectionVerticalTopToBottom) { + [self.multiFoldView setTransform:CGAffineTransformMakeTranslation(0, - (self.multiFoldView.frame.size.height - self.multiFoldView.offset))]; + } + } +} + +- (FoldState)foldState { + return self.multiFoldView.state; +} + +@end diff --git a/PaperFold/PaperFold/SinglePaperFold-Info.plist b/PaperFold/PaperFold/SinglePaperFold-Info.plist new file mode 100644 index 0000000..7989133 --- /dev/null +++ b/PaperFold/PaperFold/SinglePaperFold-Info.plist @@ -0,0 +1,42 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFiles + + CFBundleIdentifier + com.honcheng.${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 + + UIViewEdgeAntialiasing + + + diff --git a/PaperFold/PaperFold/SinglePaperViewController.h b/PaperFold/PaperFold/SinglePaperViewController.h new file mode 100644 index 0000000..cf37434 --- /dev/null +++ b/PaperFold/PaperFold/SinglePaperViewController.h @@ -0,0 +1,19 @@ +// +// SinglePaperViewController.h +// PaperFold +// +// Created by Wang Hailong on 12-12-20. +// Copyright (c) 2012年 honcheng@gmail.com. All rights reserved. +// + +#import + +@class SinglePaperFoldView; +@interface SinglePaperViewController : UIViewController + +@property (weak, nonatomic) SinglePaperFoldView *singlePaperFoldView; +@property (strong, nonatomic) IBOutlet UIView *contentView; + +- (IBAction)changeFoldOrUnfold:(id)sender; + +@end diff --git a/PaperFold/PaperFold/SinglePaperViewController.m b/PaperFold/PaperFold/SinglePaperViewController.m new file mode 100644 index 0000000..c25a7d6 --- /dev/null +++ b/PaperFold/PaperFold/SinglePaperViewController.m @@ -0,0 +1,62 @@ +// +// SinglePaperViewController.m +// PaperFold +// +// Created by Wang Hailong on 12-12-20. +// Copyright (c) 2012年 honcheng@gmail.com. All rights reserved. +// + +#import "SinglePaperViewController.h" + +#import "SinglePaperFoldView.h" + +@interface SinglePaperViewController () + +@end + +@implementation SinglePaperViewController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +#pragma mark Lift Cycle +- (void)viewDidLoad +{ + [super viewDidLoad]; + self.view.backgroundColor = [UIColor darkGrayColor]; + SinglePaperFoldView *singlePaperFoldView = [[SinglePaperFoldView alloc] initWithFrame:CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height) foldDirection:FoldDirectionHorizontalRightToLeft folds:4 pullFactor:0.9]; + [singlePaperFoldView setContent:self.contentView]; + singlePaperFoldView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin; + [self.view addSubview:singlePaperFoldView]; + self.singlePaperFoldView = singlePaperFoldView; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (void)viewDidUnload { + [self setSinglePaperFoldView:nil]; + [self setContentView:nil]; + [super viewDidUnload]; +} + +#pragma mark Button Event +- (IBAction)changeFoldOrUnfold:(id)sender { + if ([self.singlePaperFoldView foldState] == FoldStateClosed) { + [self.singlePaperFoldView unfoldPaper:YES Animation:YES]; + } + else if ([self.singlePaperFoldView foldState] == FoldStateOpened) { + [self.singlePaperFoldView unfoldPaper:NO Animation:YES]; + } +} + +@end diff --git a/PaperFold/PaperFold/SinglePaperViewController.xib b/PaperFold/PaperFold/SinglePaperViewController.xib new file mode 100644 index 0000000..18630b8 --- /dev/null +++ b/PaperFold/PaperFold/SinglePaperViewController.xib @@ -0,0 +1,262 @@ + + + + 1536 + 12C60 + 2844 + 1187.34 + 625.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 1930 + + + IBProxyObject + IBUIButton + IBUIImageView + IBUIView + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + PluginDependencyRecalculationVersion + + + + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 274 + + + + 292 + {{124, 338}, {73, 44}} + + + + _NS:9 + NO + IBCocoaTouchFramework + 0 + 0 + 1 + Change + + 3 + MQA + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + 3 + MC41AA + + + 2 + 15 + + + Helvetica-Bold + 15 + 16 + + + + {{0, 20}, {320, 460}} + + + + + 3 + MQA + + 2 + + + + + IBUISimulatedFreeformSizeMetricsSentinel + Freeform + + IBCocoaTouchFramework + + + + 292 + + + + 292 + {{10, 10}, {300, 220}} + + + + _NS:9 + NO + IBCocoaTouchFramework + + NSImage + miao.png + + + + {320, 240} + + + + _NS:9 + + 3 + MCAwAA + + + IBCocoaTouchFramework + + + + + + + view + + + + 3 + + + + contentView + + + + 14 + + + + changeFoldOrUnfold: + + + 7 + + 12 + + + + + + 0 + + + + + + 1 + + + + + + + + -1 + + + File's Owner + + + -2 + + + + + 11 + + + + + 13 + + + + + + + + 7 + + + + + + + SinglePaperViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + 14 + + + + + SinglePaperViewController + UIViewController + + changeFoldOrUnfold: + id + + + changeFoldOrUnfold: + + changeFoldOrUnfold: + id + + + + contentView + UIView + + + contentView + + contentView + UIView + + + + IBProjectSource + ./Classes/SinglePaperViewController.h + + + + + 0 + IBCocoaTouchFramework + YES + 3 + + miao.png + {640, 480} + + 1930 + +