• Stars
    star
    2,704
  • Rank 16,276 (Top 0.4 %)
  • Language
    Objective-C
  • License
    Other
  • Created almost 12 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Paper folding animation for iOS

PaperFold for iOS

PaperFold is a simple iOS control that allows hiding of views on the left and right side of the screen by dragging the middle view. The left view supports only 1 fold. The right view supports variable number of folds.

Vertical fold is still in active testing, in an experimental branch (top-multifold) at the moment.


How it works

During folding, a screen capture of the left/right view is taken, and split up depending on the number of folds required. The virtual light source is on the right side of the screen, so surfaces that faces the left are darker. For the right multi-fold view, the fold closes to the 'force' are opened up faster than the folds that is further away.

A sample project is included.

Example

Refer to this link for a video showing the prototype of an app that I was working on. In the end, the proposed project was never completed because I could not obtained reliable data for the app, but I intend to use it for another app.

The animation here looks a bit laggy, but that's because of the low frame rates in GIF.

Usage

  1. Add PaperFoldView as a subview into your view controller.

    _paperFoldView = [[PaperFoldView alloc] initWithFrame:CGRectMake(0,0,100,[self.view bounds].size.height)]; [self.view addSubview:_paperFoldView];

  2. To set left view, use setLeftFoldContentView:foldCount:pullFactor:. Example below uses a UITableView, but it can any UIView.

    _leftTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,100,[self.view bounds].size.height)]; [_paperFoldView setLeftFoldContentView:_leftTableView foldCount:3 pullFactor:0.9];

  3. To set the right view, use setRightFoldContentView:foldCount:pullFactor:. Example below uses a MKMapView, but it can any UIView. The fold count is the number of folds in the right view. The pull factor controls the ratio of folding/unfolding of the different folds away from the center.

    _mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0,0,240,[self.view bounds].size.height)]; [_paperFoldView setRightFoldContentView:_mapView foldCount:3 pullFactor:0.9];

  4. To set the center view

    _centerTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,[self.view bounds].size.height,[self.view bounds].size.height)]; [_paperFoldView setCenterContentView:_centerTableView];

  5. Sometimes you may want to disable drag-to-unfold if you have a table view in the center view and wish to preserve the swipe gesture functions e.g. to delete cells.

    // this disables dragging to unfold the left view [self.paperFoldView setEnableLeftFoldDragging:NO];

    // this disables dragging to unfold the right view [self.paperFoldView setEnableRightFoldDragging:NO];

  6. To unfold left view without dragging

    [self.paperFoldView setPaperFoldState:PaperFoldStateLeftUnfolded];

  7. To unfold right view without dragging

    [self.paperFoldView setPaperFoldState:PaperFoldStateRightUnfolded];

  8. To restore view to center without dragging

    [self.paperFoldView setPaperFoldState:PaperFoldStateDefault];

  9. To receive callbacks when fold state changes, and if the fold was activated manually by finger gesture, or automatically by calling setPaperFoldState:

    // register callback delegate [self.paperFoldView setDelegate:self];

    // callback comes from the following delegate method

    • (void)paperFoldView:(id)paperFoldView didFoldAutomatically:(BOOL)automatic toState:(PaperFoldState)paperFoldState

Requirements

This project uses ARC. If you are not using ARC in your project, add '-fobjc-arc' as a compiler flag for all the files in this project. XCode 4.4 is required for auto-synthesis.

Apps that uses PaperFold

Showy , LargeType , NextRide , SG NextBus , Hangzhou Metro

Contact me if you want your app listed here. Thanks

Other Projects that uses PaperFold

PaperFoldMenuController by me.

PaperFold CocoaPod Demo for RubyMotion by yestoall.

Titanium Mobile Mobule for PaperFold by atsusy.

Known Problem

Screen capture of MKMapView is iOS6 is not taken properly. I approached a few Apple engineers at WWDC, and was told that it is most likely a bug that need to fix. I have already filed a bug report (filed as rdar://11813051, closed by Apple because it is a duplicate of rdar://11650331). Hopefully it will be fixed soon.

Update: This bug is fixed in iOS6b4. No problem taking screenshot of MKMapView.

Credits

Special thanks to @dilliontan, my colleague in buUuk for explaining CAAffineTransform. He's a master at that :p. I'm still a noob. You can check out his iOS-Flip-Transform project here.

Contact

twitter.com/honcheng honcheng.com

More Repositories

1

RTLabel

simple rich text display for iOS using html-like markups
Objective-C
1,459
star
2

iOSPlot

Chart library for iOS
Objective-C
1,372
star
3

iOS-StyledPageControl

Customizable PageControl for iOS
Objective-C
527
star
4

PaperFoldMenuController

A navigation menu on the left of the screen using on PaperFold
Objective-C
436
star
5

PaperFoldGallery

PaperFoldGallery for iOS
Objective-C
359
star
6

CATransform3D-Test

A test app to visualize view transformation when value in CATransform3D matrices change
Objective-C
352
star
7

PanelTableView

Multiple UITableViews in a UIScrollView
Objective-C
202
star
8

StyledTableViewCell-for-iOS

Customize table view cell border and highlights
Objective-C
195
star
9

SliderPageControl-for-iOS

An alternative for UIPageControl
Objective-C
137
star
10

AcornCharts-for-iOS

Fun way to display charts using balls that responds to device tilting
Objective-C
113
star
11

ScrollableTabHost-for-Android

Java
90
star
12

iOS-nodechat

iOS chat client for socket.io & node.js backend
Objective-C
70
star
13

GAE-APIMonitor

Google AppEngine application that monitors server API
Python
25
star
14

GAEMobileAnalytics

Google AppEngine Analytics for Mobile Applications
Objective-C
17
star
15

CAMediaTimingFunctionVisualizer

iPad app to preview animation based on custom animation curve created
Objective-C
17
star
16

Singapore-Bus-Services

Singapore Bus Services
6
star
17

rfremote-fan-api

API to control RF fan using pilight in Raspberry Pi
Python
5
star
18

SubRip-Parser-for-iOS

Objective-C
5
star
19

homebridge-rfremote-fan

HomeBridge plugin to replace RF remote control for fans
JavaScript
3
star