GithubHelp home page GithubHelp logo

bcgenieeffect's Introduction

BCGenieEffect

OSX style genie effect inside your iOS app.

Features

  • UIView category
  • Custom destination/start rectangle and its edge
  • CoreAnimation based

How To Use

Genie in

CGRect endRect = CGRectMake(30, 40, 50, 60);
[view genieInTransitionWithDuration:0.7 
                    destinationRect:endRect 
                    destinationEdge:BCRectEdgeTop 
                         completion:^{
                          	NSLog(@"I'm done!");
                          }];

Genie out

CGRect startRect = CGRectMake(30, 40, 50, 60);
[view genieOutTransitionWithDuration:0.7 
                           startRect:startRect
                           startEdge:BCRectEdgeLeft 
                          completion:nil];

Parameters

Both endRect and startRect should be specified in coordinates of view's superview.

The edge parameter is one of the four rect's edges:

  • BCRectEdgeTop
  • BCRectEdgeLeft
  • BCRectEdgeBottom
  • BCRectEdgeRight

Positioning limitations

Due the way BCGenieEffect works there are some limitations in spacing between animated view and destination rect. For the following examples we will assume that the destination edge is BCRectEdgeTop.

Correct positioning

Let's start with situations in which animation will work. As you can see there is a clear and logical path which animated view will follow, it slips into the destination rect easily.

Unadvisable positioning

While this example might seem similar, you should notice that the bottom edge of animated view is below the top edge of destination rect. While on OSX the window will move up so that its bottom edge is above the dock, I've decided not to implement this autocorrection. BCGenieEffect will still perform the animation, however the results might be glitchy. It is advised that you either decide that the glitch is not important or manually move/animate the view to evade the problem. When unadvisable positioning occurs, BCGenieEffect will NSLog a warning into console:

Genie Effect Warning: The bottom edge of animated view overlaps top edge of destination rect. Glitches may occur.

Incorrect positioning

The picture presents situation in which BCGenieEffect will not fire at all, since the requested animation curve is irrational. Positioning the view correctly will remove the problem.

As before, BCGenieEffect will notify you of a problem by spilling NSLog into console:

Genie Effect ERROR: The distance between top edge of animated view and top edge of destination rect is incorrect. Animation will not be performed!

Requirements

  • iOS 5.0
  • ARC
  • QuartzCore framework in your project

Contact

Bartosz Ciechanowski

@BCiechanowski

License

BCGenieEffect is released under an MIT license.

Copyright (c) 2012 Bartosz Ciechanowski

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.

bcgenieeffect's People

Contributors

bmwlogic avatar ciechan avatar fillito 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

bcgenieeffect's Issues

Question: Is it safe to use on iOS5.0?

Hi,

First of all thanks for this, it works great and I was able to apply within merely seconds. My question is, why is this control marked as iOS 5.1? I have it running on iOS 5.0 without any problem?

Thanks,
Ege

Support : How can i apply this effect to a UITableViewCell

Hi, you have done a good job!

I am interested with this effect and i want to apply this effect as delete animation to my table view cell, on to a button which is on the out side view(super view)

can you suggest me to achieve this

Section Header above Genie animation

The section headers of the super TableView floats above the view dismissed with the genie effect. So far, I've been unsuccessful in fixing it. Any tips or suggestions?

I've just catched Assertion failed: (t >= 0 && t <= 1.0)

I've played with animation and minimize and restore app many times.

Assertion failed: (t >= 0 && t <= 1.0), function bezierAxisIntersection, file /Users/k06a/Projects/Pictography/Pictography/UIView+Genie.m, line 509.

Here is my suppose (I don't saw your code detailed):
I think your method was called, then paused for long time, then resumed, checked real time and it is greater then 1.0

Vertical ScrollView

This lib is really awesome, I love it, but unfortunately it doesn't works with vertical scrollView on 1+ pages. It's fine just on first page. On other pages there is no animation. I tried to find the problem, but you have much more experience, and I didn't really understood you code. Is there any solution for this issue? I can send you an example project, to demonstrate my problem.

iOS 5.0 requirement

I've been looking through the code and can't find a single ios5+ API used. It's kinda hard to test against iOS4 these days – is there any particular reason it won't work?

PS: thanks for the lib – animation looks really cool!

Major memory crashes when using this nice animation

Hi,

i was using your awesome animation, but was investigating a major memory crash in our app and found that the genieInTransition call is causing it because of unbounded memory growth that is not released. Everytime it is called, the memory is growing by 3MB and not reclaimed back. Now with Xcode 5, it is clearly shown in the execution pane and also when going to profiler from there.

Essentially, we are just creating a UIImageView and rendering the current screen to that using straightforward code from Apple:

-(UIImage *)snapshot()
{
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}

UIImageView *ss = [[UIImageView alloc] initWithFrame:self.view.bounds];
ss.image = [self snapshot];
[ss genieInTransitionWithDuration:0.7
destinationRect:endRect
destinationEdge:BCRectEdgeTop
completion:^{

In XCode instruments, the allocations show huge nearly 3MB growth as below:

Event Type ∆ RefCt RefCt Timestamp Responsible Library Responsible Caller
0 VM Alloc 02:08.145.871 CoreGraphics CGDataProviderCreateWithCopyOfData

The LiveBytes increases by 3MB everytime the genieInTransition is called.
Graph Category Live Bytes # Living # Transient Overall Bytes # Overall Bytes Allocated (Net / Overall)
1 All Heap & Anonymous VM 12.16 MB 11263 3422178 597.30 MB 3433441 <XRRatioObject: 0x7fbca501d950> %0.02, %0.98

It does not increase if the genie call is not made - so our app is crashing. We have the latest code with the previous memory fix in July or so.

I've looked at your code, but could not find any obvious leaks - but the code is complex - I'd appreciate your help - rendering the screen to an image is a core part of the functionality.

Thanks,
BH

Crash in UIView(Genie) transformationsForSlices:edge:startPosition:totalSize:firstBezier:secondBezier:finalRectDepth:

We see a crash in production inside transformationsForSlices:edge:startPosition:totalSize:firstBezier:secondBezier:finalRectDepth: using version 1.1 of this library via CocoaPods. This crash account for about 4% of our app's total crashes. The crash is SIGABRT on UIView+Genie.m:357:

assert(sign*(startPosition - rectPartStart) <= 0.0);

Here is a sample full stack trace:

Thread 0 Crashed:
0   libsystem_kernel.dylib               0x3787bc84 __pthread_kill + 8
1   libsystem_pthread.dylib              0x3791bb47 pthread_kill + 60
2   libsystem_c.dylib                    0x37813f41 abort + 106
3   libsystem_c.dylib                    0x377f36cf __assert_rtn + 300
4   appname                           0x00211e77 -[UIView(Genie) transformationsForSlices:edge:startPosition:totalSize:firstBezier:secondBezier:finalRectDepth:] (UIView+Genie.m:357)
5   appname                           0x00210ef5 -[UIView(Genie) genieTransitionWithDuration:edge:destinationRect:reverse:completion:] (UIView+Genie.m:226)
6   appname                           0x002103d7 -[UIView(Genie) genieOutTransitionWithDuration:startRect:startEdge:completion:] (UIView+Genie.m:128)
7   appname                           0x0010e2f3 -[EAStoreViewController transitionInWithCompletion:] (EAStoreViewController.m:165)
8   appname                           0x000f6291 __63-[EAFamilyViewController _popChildAnimated:options:completion:]_block_invoke (EAFamilyViewController.m:418)
9   UIKit                                0x29b0ca55 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 538
10  UIKit                                0x29b0c531 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 202
11  UIKit                                0x29b0c42b -[UIViewAnimationState animationDidStop:finished:] + 76
12  QuartzCore                           0x2939c5cf CA::Layer::run_animation_callbacks(void*) + 252
13  libdispatch.dylib                    0x37783e1b _dispatch_client_callout + 20
14  libdispatch.dylib                    0x377886c9 _dispatch_main_queue_callback_4CF + 1530
15  CoreFoundation                       0x25960535 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 6
16  CoreFoundation                       0x2595ea2f __CFRunLoopRun + 1588
17  CoreFoundation                       0x258b10d9 CFRunLoopRunSpecific + 514
18  CoreFoundation                       0x258b0ecd CFRunLoopRunInMode + 106
19  GraphicsServices                     0x2ec26af9 GSEventRunModal + 158
20  UIKit                                0x29b3a2dd UIApplicationMain + 142
21  appname                           0x0007b02f main (main.m:16)
22  libdyld.dylib                        0x377ac873 start + 0

SIGABRT inside bezierAxisIntersection on iPhone 4S (iOS 5.1.1)

I have an SIGABRT on iPhone 4S (iOS 5.1.1)

2 libsystem_c.dylib 0x32dfc7ec _sigtramp + 48
3 libsystem_c.dylib 0x32df220e pthread_kill + 54
4 libsystem_c.dylib 0x32deb29e abort + 94
5 libsystem_c.dylib 0x32e0bcc0 asl_core_string_hash + 0
6 Pictography 0x00050b1e bezierAxisIntersection (UIView+Genie.m:485)
7 Pictography 0x00050668 -[UIView(Genie) transformationsForSlices:edge:startPosition:totalSize:firstBezier:secondBezier:finalRectDepth:] (UIView+Genie.m:353)
8 Pictography 0x0004f74e -[UIView(Genie) genieTransitionWithDuration:edge:destinationRect:reverse:completion:] (UIView+Genie.m:220)
9 Pictography 0x0004ee9e -[UIView(Genie) genieOutTransitionWithDuration:startRect:startEdge:completion:] (UIView+Genie.m:128)

I can't reproduce this problem.
This backtrace I just got from TestFlightApp.com
Why this can happen?

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.