Giter Site home page Giter Site logo

mpospese / mpfoldtransition Goto Github PK

View Code? Open in Web Editor NEW
1.8K 83.0 238.0 249 KB

Easily add custom folding and page-flipping transitions to UIViews and UIViewControllers

Home Page: http://markpospesel.com/2012/05/07/mpfoldtransition/

Objective-C 100.00%

mpfoldtransition's Introduction

MPTransition

Update: MPTransition now comprises MPFoldTransition and MPFlipTransition

Update 2: For a touch gesture-enabled container controller with page-flipping (not just a transition), see MPFlipViewController

MPFoldTransition is a set of classes to add folding-style transitions to iOS 5 projects.
iPhone Fold
MPFlipTransition is a set of classes to add page-flipping transitions to iOS 5 projects.
iPhone Flip
I built it using ARC (and for the demo portion storyboards) strictly for convenience, so it uses iOS 5. I imagine the relevant code (minus the UIStoryboardSegue helper classes) could be easily ported to iOS 4.3 under ARC, or ported to iOS 4.0 with memory management inserted. (Hint: If you're porting to non-ARC, you'll need to retain [sourceView superView] in the init method.)

Features

  • Convenience methods to extend UIViewController to present/dismiss a view controller modally using fold/flip transitions
  • Convenience methods to extend UINavigationController to push/pop view controllers onto the navigation stack using fold/flip transitions
  • Convenience methods to transition between any 2 UIViewControllers or UIViews
  • 3 Custom UIStoryboardSegue subclasses to easily add folding/flipping transitions via Interface Builder in your storyboards
  • Fully customizable to adjust style, duration, timing curves, and completion action
  • Blocks-based: many methods include a completion block parameter following the pattern of block-based animations introduced in iOS 4.

Fold Styles

Currently there are 3 style bits that can be combined for 8 different styles.

  • Direction: Fold vs. Unfold
    Fold vs. Unfold
  • Mode: Normal vs. Cubic
    Normal vs. Cubic
  • Orientation: Vertical vs. Horizontal
    Vertical vs. Horizontal

Flip Styles

Currently there are 3 style bits that can be combined for 8 different styles.

  • Direction: Forward vs. Backward
    Forward vs. Backward
  • Orientation: Horizontal vs. Vertical
    Horizontal vs. Vertical
  • Perspective: Normal vs. Reverse
    Normal vs. Reverse

Requirements

  • Xcode 4.4 or higher
  • LLVM compiler
  • iOS 5 or higher

How To Use

See the "MPFoldTransition.h" (and "MPFlipTransition.h") header file(s) for methods and use the demo project as a reference. The Segue classes (under directory of the same name) are optional, only if you want to include storyboard support. Otherwise you just need the classes under the bottommost MPFoldTransition directory.

Licensing

Read Source Code License.rtf, but the gist is:

  • Anyone can use it for any type of project
  • All I ask for is attribution somewhere

Support, bugs and feature requests

There is absolutely no support offered with this component. You're on your own! If you want to submit a feature request, please do so via the issue tracker on github.

If you want to submit a bug report, please also do so via the issue tracker, including a diagnosis of the problem and a suggested fix (in code). If you're using MPTransition, you're a developer - so I expect you to do your homework and provide a fix along with each bug report. You can also submit pull requests or patches.

Please don't submit bug reports without fixes!

(The preceding blurb provided courtesy of the legendary Matt Gemmell)

Best,
Mark Pospesel

Website: http://markpospesel.com/
Contact: http://markpospesel.com/about
Twitter: http://twitter.com/mpospese
Hire Me: http://crazymilksoftware.com/

mpfoldtransition's People

Contributors

cbowns avatar mpospese avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mpfoldtransition's Issues

Flip transition from top to bottom

Hi guys,
Do you know how can I flip from top to bottom with this library ? Because the MPFlipStyle enum (inside the MPFlipEnumerations header) does not contains the value to do that:

enum {
    // current view folds away into center, next view slides in flat from top & bottom
    MPFlipStyleDefault              = 0,
    MPFlipStyleDirectionBackward    = 1 << 0,
    MPFlipStyleOrientationVertical  = 1 << 1,
    MPFlipStylePerspectiveReverse   = 1 << 2
};
typedef NSUInteger MPFlipStyle;

*Default and DirectionBackward is regarding the horizontal direction and the third one, MPFlipStyleOrientationVertical is for the vertical direction but it's from bottom to top. The last one is the perspective reverse which is not useful to me.

Thanks in advance,
Diego

Non-equal sized views

Hello,

first of all, thanks everybody involved in this projects. It is an awesome library.
I am trying to use it with different sized views (actually double height OR double width, for example 100x100 transition to 100x200). It should work like if you unfold a paper which is folded in the middle... ¿Does anybody know how can I do that?
Of course I know a solution could be put the first view in a double sized container but I would prefer to not use that kind of tricky things.

Many thanks in advance, and sorry for my English.

MPFoldTransition is broken on iPhone X

The fold transition doesn't take into account the iOS 11 safe area insets. Therefore, transitions fill the safe area during the animation followed by the view abruptly filling it's intended area at the transition's end.

untitled

cocoapods

Hey,

It would be nice to tag and add it to the cocoapods projet as a spec, specially for people using it to have a version control

Cheers

When presenting a NavigationController, the snapshot image is incorrect

I want to present a Modal View controller, which is an instance of UINavigationController.

How to Reproduce: embed the about view controller inside a UINavigationController

  • (IBAction)infoPressed:(UIBarButtonItem *)sender {
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:[AppDelegate storyboardName] bundle:nil];
    AboutViewController *about = [storyboard instantiateViewControllerWithIdentifier:ABOUT_IDENTIFIER];

    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:about];
    [about setModalDelegate:self];

    if ([self isFold])
    [self presentViewController:nav foldStyle:[self foldStyle] completion:nil];
    else
    [self presentViewController:nav flipStyle:[self flipStyle] completion:nil];
    }

Root Cause: the snapshot height is minus 20 by mistake, and the 20 is the height of the statusbar, so I think the calculation of
rect in MPTransition is incorrect. In above test case, the rect value should be {{0, 0}, {320, 416}}, but it is changed to {{0, 20}, {320, 460}} in the - (void)setPresentingController:(UIViewController *)presentingController method of MPTransition class.

@Property (assign, nonatomic) CGRect rect;

Would you please help to look at this issue? thanks a lot.

ViewDidLoad is calld after transition.

Hi, Thank you so much for your code but i have a little problem. The view loads its data after it shows up as a design point it doesn't look good. For example do you notice when you push or percent a view with apples transitions it waits a few seconds and then loads the view.

Thanks again,
TheAppleWizz

Tab bar app.

Hi

I want to add view transition between tabs view controller. How can I do ?

note: I am using storyboard.

Custom Skew and "Swing Animations"

How would I going about changing the skew of the transition. For example lets say I placed two transitioning views side by side (like one of those old scoreboards flip scores), and wanted to have one flipping as if a little towards the left, and the other a little towards the right.

Also, sort of related ... if I wanted to create the effect of the view "swinging" and "bouncing" back into place, any way to customize the transition for this? Imagine the new view would transition a bit past vertical, almost appearing to go backwards for a sec, and then transitioning back to being straight. Makes sense?

Fake flip

Thanks for the great library!

I am using the flip to navigate through an array. when i reach the beginning / end of the array, is it possible to add a fake flip animation to indicate that there is no more page?

i.e. lift up the layer a bit and put it down

Thanks!

Hard switch in UINavigationBar when using UINavigationController category

Hi,

I'm using the category on UINavigationController to animate push/pop using a fold transition. The animation of the content area is perfect, however at the end of the animation, the UINavigationBar is hard switched over to the new content, which looks a bit disturbing. Is there a way to fix this, i.e. using a crossfade on the UINavigationBar?

I tried to create a cross-fade animation of the UINavigationBar main layer in the transition completion block where the non-animated push is being performed, but that didn't change anything.

delay on device

Hi all,
I'm having a strange issue. In the simulator, no delay to push a view controller.
But on the device, there's a delay of 1 to 2 seconds before the animation starts.. (i0S 6.1.2, iPhone 5)

Here's the code i'm using :

[self.navigationController pushViewController:VC foldStyle:MPFoldStyleUnfold];

Any ideas why i have a delay on the device ?
I really want to use this library in my project, but i can't deliver it with this delay...

UIViews with transparent backgroundColor

If I use this style: (MPFoldStyleHorizontal | MPFoldStyleUnfold | MPFoldStyleCubic) and 'toView' has a transparent background, the 'fromView' should not be visible (after it has been flipped) behind the 'toView'.

I think a possible solution could be stop to render 'fromView' if it has been flipped: (right < left || top < bottom)


if I use this style: (MPFoldStyleHorizontal | MPFoldStyleUnfold) and 'fromView' has a transparent background, a black background is added to 'fromView' when the transition starts.

This problem is in: [MPAnimation renderImageFromView:...] and can be fixed forcing a non-opaque background if the view.backgroundColor == UIColor clearColor ... (maybe there's a better solution):

UIGraphicsBeginImageContextWithOptions(imageSizeWithBorder, FALSE, 0);


Thanks for this great library.

Missing doInit declaration in some .h files ?

I tried to build & run directly your project and it failed at compile time saying that the doInit method was not declared in several files?

I resolved the problem adding the declaration of the doInit method on those files. However, I'm an Obj-C newbie and I'd like to know for sure that this is a normal thing or maybe is that I'm missing some configuration related to ARC.

Thanks,
Jose

iOS8 bugs

Thanks for a great library.

I've just updated to iOS8 and I have a problem, though. On transitioning to a new view controller using - (void)presentViewController:flipStyle:completion:, I get a brief flash of the original view controller just following the transition. On transitioning back, the transition appears to complete in about 2 frames, so is barely noticeable.

I haven't yet tried investigating where this behaviour is coming from, but it was working beautifully on iOS7 ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.