UI framework to emulate paper folding effects.

Overview

FTFoldingPaper

Build Status Version License Platform

FTFoldingPaper is a UI framework built on top of the Core Animation. It is designed to emulate paper folding effects and can be integrated with UITableView, used independently or paired with other UI components.

ftfoldingpaperexample

How To Get Started

  • Download FTFoldingPaper and try it out.
  • Install FTFoldingPaper to your project using CocoaPods.
  • Follow instructions below.

Installation with CocoaPods

CocoaPods is a dependency manager, which automates and simplifies the process of using 3rd-party libraries like FTFoldingPaper in your projects.

You can install CocoaPods with the following command:

$ sudo gem install cocoapods

Then execute:

$ cd <path to your project folder>
$ pod init

Open pod file for edit with Xcode or another editor:

$ open -a Xcode podfile

Add the following text under "target 'your project name' do" line:

pod 'FTFoldingPaper'

Finally, execute:

$ pod install

You're done! Now open your project by clicking on the newly created xcworkspace file.

Architecture:

ftfoldingpaperstructure

Paper folding animation:
FTFoldComponent
FTAnimationView
FTAnimationContext
FTParentLayerAnimations
FTFoldComponentAnimations
FTFoldComponentGradientAnimations

Integration with UITableView:
FTViewController
FTTableModel
FTTableCellMetadata
FTTableView
FTTableCell
FTTableCellSeparator

Usage:

  1. Create xibs of the top and bottom layers for all your fold components.
    Note that each fold component requires top and bottom layers.

    1.1 Press '⌘ + N'. Select "User Interface" -> "View"
    1.2 Open and edit each xib according to your needs: (add UI components, setup Autolayout).
    1.3 Create data model object to manage UI components of your layer, if any required.

  2. Subclass and configure FTAnimationView with FTFoldComponents and FTAnimationContext.

FTAnimationView hosts fold components and manages animation. Animation process is configured with FTAnimationContext

Override the next two methods in FTAnimationView:

/* example of animation view with 2 fold components*/
-(NSArray *)submitFoldComponents{

FTFoldComponent *foldComponentA = [[FTFoldComponent alloc]initWithSuperView:self
topViewNibName:@<your top layer xib name>
bottomViewNibName:@<your bottom layer xib name>];

FTFoldComponent *foldComponentB = [[FTFoldComponent alloc]initWithSuperView:self
topViewNibName:@<your top layer xib name>
bottomViewNibName:@<your bottom layer xib name>];

return @[foldComponentA,foldComponentB];
}

/* please refer to FTAnimationContext interface to get the 
full list of possible configuration parameters */

-(void)configureAnimationContext:(FTAnimationContext *)animationContext{

animationContext.expandAnimationDuration = 0.6f;
animationContext.collapseAnimationDuration = 0.6f;
animationContext.foldAngleFinalValue = - M_PI/6;
animationContext.animationMediaTimingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
}

At this point you have FTAnimationView that is ready to be used in your UI. Continue with steps 3 - 7 if you need to integrate it into the UITableView component.

Usage with UITableView:

  1. Subclass FTTableCell and create cell prototype. You can create as many different cells as you need in order to fulfill your UI tasks.

    3.1 Press '⌘ + N'. Create new subclass of UITableViewCell. Tick "Also create XIB file".
    3.2 Open .h file of your class. Change parent class to FTTableCell like this:

    @interface <your class name> : FTTableCell

    3.3 Open and edit cell xib according to your needs: (add UI components, setup Autolayout).
    3.4 Create data model object to manage UI components of your cell if any required.
    3.5 Set cell identifier.

  2. Configure each subclassed FTTableCell with FTAnimationView and FTTableCellSeparator overriding following methods in FTTableCell:

-(FTAnimationView *)submitAnimationView{
return [[<name of your FTAnimationView subclass> alloc]init];
}


/* do not override if you need cell without separator */
-(FTTableCellSeparator *)submitCellSeparator{
return [[FTTableCellSeparator alloc]initWithHeight:1.0f
offsetFromCellLeftEdge:0.0f
offsetFromCellRightEdge:0.0f
color:[UIColor colorWithRed:92.0f/255.0f green:94.0f/255.0f blue:102.0f/255.0f alpha:0.1f]];
}
  1. Subclass and configure FTTableModel. FTTableModel is responsible for the architecture of your table view: which cells are used and in which order. It can manage FTTableCell and UITableViewCell cells in any combinations.

Override the following methods in FTTableModel:

-(NSDictionary *)submitCellsIDs{

return  @{@"<id of your cell>":@"<xib name of your cell>"};

}

/* Submit your table architecture. In this example, the table consists only of cells of one type. You can implement any custom architecture combining different cell types for different rows */

-(NSArray *)submitTableCellsMetadata{

NSMutableArray *cellsMetadata = [[NSMutableArray alloc]init];

for (NSInteger i = 0; i < kNumberOfCellsInTable; i++) {

FTTableCellMetadata *tableCellMetadata = nil;

tableCellMetadata = [[FTTableCellMetadata alloc]initWithReuseID:@"<xib name of your cell>" isExpandable:YES isExpanded:NO];

[cellsMetadata addObject:tableCellMetadata];
}

return cellsMetadata;
}
  1. Add TableView UI component to your controller in the storyboard.

    6.1 Configure your TableView UI component.
    6.2 Set FTTableView as the custom class for your table (in storyboard settings).

  2. Subclass and configure FTTableViewController.
    FTTableViewController bridges FTTableView with FTTableModel and provides other logic to manage cells operations.

    7.1 In your subclassed FTTableViewController, link your FTTableView and subscribe for UITableViewDelegate and UITableViewDataSource protocols. Example:

    self.tableView.dataSource = self;
    self.tableView.delegate = self;

    7.2 Override the following methods in your subclassed FTTableViewController:

    -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [super tableView:tableView numberOfRowsInSection:section];
    }
    
    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    return [super tableView:tableView cellForRowAtIndexPath:indexPath];
    }
    
    -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return [super tableView:tableView heightForRowAtIndexPath:indexPath];
    }
    
    -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    [self updateDisplayedDataForCell:cell atIndexPath:indexPath];
    }

    7.3 Implement your data model to manage the content of your cells.
    7.4 Implement mechanism to update the content of your cells using your data model.
    You can override -(void)tableView: willDisplayCell: forRowAtIndexPath: for that purpose.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

You might also like...
Interactive view transition to display menus with flowing and bouncing effects in Swift
Interactive view transition to display menus with flowing and bouncing effects in Swift

FlowingMenu FlowingMenu provides an interactive transition manager to display menu with a flowing and bouncing effects. The Objective-C countepart is

Custom UITextFields effects inspired by Codrops, built using Swift
Custom UITextFields effects inspired by Codrops, built using Swift

TextFieldEffects I fell in love with the text inputs effects in this article. As an exercise I decided to recreate as many of them as I can using Swif

SwiftUI Animation Library. Useful SwiftUI animations including Loading/progress, Looping, On-off, Enter, Exit, Fade, Spin and Background animations that you can directly implement in your next iOS application or project. The library also contains huge examples of spring animations such as Inertial Bounce, Shake, Twirl, Jelly, Jiggle, Rubber Band, Kitchen Sink and Wobble effects. Browse, find and download the animation that fits your needs. A not bad gooey effects menu.
A not bad gooey effects menu.

带粘性的扇形菜单 Path menu with gooey effectes. 灵感来自这个Dribbble设计: Inspired by this dribbble: ###下面是实现的效果: ###Here is what the repo can do: 1、点击每个具体的菜单可以获得相应的编

Instant camera hybrid with multiple effects and filters written in Swift.
Instant camera hybrid with multiple effects and filters written in Swift.

Kontax Cam Download on the app store! No longer on the app store Kontax Cam is an instant camera built 100% using Swift for iOS. You can take your pho

 iOS multi-functional AI camera: portrait cartoon, ageing and rejuvenation, beauty, filters, artistic effects, etc.
iOS multi-functional AI camera: portrait cartoon, ageing and rejuvenation, beauty, filters, artistic effects, etc.

Magic Camera is an iOS AI camera app based on SwiftUI and CoreML that implements the following features: Portrait Cartoonization, which turns your photos into cartoon avatars Portrait Style Migration, which makes your photos older, younger, hair color, etc Beauty Camera, which supports peeling

A view that takes a set of images, make transition from one to another by using flipping effects.
A view that takes a set of images, make transition from one to another by using flipping effects.

CDFlipView A view that takes a set of images, make transition from one to another by using flipping effects. Demo Live Demo: https://appetize.io/app/w

Show the weather effects onto view written in Swift4.2
Show the weather effects onto view written in Swift4.2

URWeatherView What is this for? Showing some kinds of the weather effect, written in Swift4.2. This code style is the Protocol Oriented Programming. T

A beautiful activity indicator and modal alert written in Swift (originally developed for my app DoodleDoodle) Using blur effects, translucency, flat and bold design - all iOS 8 latest and greatest
A beautiful activity indicator and modal alert written in Swift (originally developed for my app DoodleDoodle) Using blur effects, translucency, flat and bold design - all iOS 8 latest and greatest

SwiftSpinner SwiftSpinner is an extra beautiful activity indicator with plain and bold style. It uses dynamic blur and translucency to overlay the cur

Simple calculation to render cheap water effects.
Simple calculation to render cheap water effects.

Water Simple calculation to render cheap water effects. This simple project demonstrates : how to use Metal draw compute shader, or known as 'kernal f

Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions
Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions

Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions. Every animation is randomized. Currently supported animations:

This is a UI lib for iOS. Effects like shining.
This is a UI lib for iOS. Effects like shining.

WCLShineButton This is a UI lib for iOS. Effects like shining. Chinese (Simplified): 中文说明 博客介绍 CocoaPods CocoaPods is the recommended way to add WCLSh

A UINavigationBar extension to show loading effects
A UINavigationBar extension to show loading effects

BusyNavigationBar A UINavigationBar extension to show loading effects above navigation bar's background. Screenshot Stripes Bars Your custom layer Usa

Parallax Scroll-Jacking Effects Engine for iOS / tvOS
Parallax Scroll-Jacking Effects Engine for iOS / tvOS

Parade Introduction Communicating to cells inside of UICollectionViews, UITableViews, or UIScrollViews, has always been a challenge. It almost always

Creating Custom Audio Effects - Simple Universal Version (Mac Catalyst)

Creating Custom Audio Effects - Simple Universal Version (Mac Catalyst) Adaptation of the sample provided by Apple Creating Custom Audio Effects. Ever

Awesome IOS Styling with SwiftUI, Animation, Effects, Gesture ⭐️

Awesome SwiftUI Styling with SwiftUI ⭐️ This repository is dedicated to IOS styling using SwiftUI. (often using Other Libraries.) I started collecting

UILabel subclass to perform text effects
UILabel subclass to perform text effects

CharacterText uses NSLayoutManager to position CATextLayers for each glyph in your string. This gives you the power to create some neat text effect using all the attributes of CATextLayer.

Get  a photo which has effects like the system camera’s Portrait mode (on compatible devices).
Get a photo which has effects like the system camera’s Portrait mode (on compatible devices).

Blurring background like Portrait mode in the iPhone camera If we want to have the blurring effect like the Portrait mode in the iOS Camera app. What

The Effects Library allows developers to create sophisticated and realistic particle systems such as snow, fire, rain, confetti, fireworks, and smoke with no or minimal effort.
The Effects Library allows developers to create sophisticated and realistic particle systems such as snow, fire, rain, confetti, fireworks, and smoke with no or minimal effort.

The Effects Library allows developers to create sophisticated and realistic particle systems such as snow, fire, rain, confetti, fireworks, and smoke with no or minimal effort.

Owner
null
Allows you to emulate an Android native library, and an experimental iOS emulation

unidbg Allows you to emulate an Android native library, and an experimental iOS emulation. This is an educational project to learn more about the ELF/

Banny 2.5k Dec 30, 2022
iOS library Paper Onboarding is a material design UI slider written on Swift.

iOS library Paper Onboarding is a material design UI slider written on Swift. We specialize in the designing and coding of custom UI

Ramotion 3.2k Jan 5, 2023
Convert the image to hexadecimal to send the image to e-paper

ConvertImageToHex Convert the image to hexadecimal to send the image to e-paper Conversion Order // 0. hex로 변환할 이미지 var image = UIImage(named: "sample

Hankyeol Park 0 Feb 26, 2022
Rock - Paper - Scissors game. CPU gives you a sign and asks to win or lose your move. Than you have to decide witch sign do you choose to score a point

RockPaperScissors 2nd challange from HackingWithSwift.com. The CPU gives you a sign (rock, paper or scissors) and asks you either to win or to lose th

Pavel Surový 0 Nov 27, 2021
Brain training Rock, Paper, Scissors game where user must purposefully win or lose against computer

RockPaperScissors This is a Rock, Paper, Scissors game that includes an addition

Bogdan Alex Ciobanu 0 Dec 18, 2021
A peer-to-peer rock, paper scissors game for iOS and macOS

RPS - Rock, Paper, Scissors! Source code for my first SwiftUI tutorial. RPS utilizes the MultipeerConnectivity framework to connect devices directly w

Joe Diragi 3 Nov 14, 2022
High-performance and flexible video editing and effects framework, based on AVFoundation and Metal.

High-performance and flexible video editing and effects framework, based on AVFoundation and Metal.

BearRuan 650 Dec 30, 2022
An iOS library to natively render After Effects vector animations

Lottie for iOS, macOS (and Android and React Native) View documentation, FAQ, help, examples, and more at airbnb.io/lottie Lottie is a mobile library

Airbnb 23.6k Dec 31, 2022
Kanvas is an open-source iOS library for adding effects, drawings, text, stickers, and making GIFs from existing media or the camera.

Kanvas Kanvas is an open-source iOS library for adding effects, drawings, text, stickers, and making GIFs from existing media or the camera.

Tumblr 267 Nov 24, 2022
Custom segue for OSX Storyboards with slide and cross fade effects (NSViewControllerTransitionOptions)

CustomSegue Custom segue for OSX Storyboards. Slide and cross fade effects, new customized window. class MyViewController: NSViewController { overr

Eric Marchand 123 May 21, 2022