Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added ._README.md
Binary file not shown.
80 changes: 1 addition & 79 deletions README.md
@@ -1,81 +1,3 @@
## UIViewController+KNSemiModal Category

UIViewController+KNSemiModal is an effort to make a replica of **semi-modal view with pushed-back stacked animation** found in the beautiful [Park Guides by National Geographic](http://itunes.apple.com/us/app/national-parks-by-national/id518426085?mt=8) app. You can see this original semi-modal view below.

This library (ARC) is designed as a Category to UIViewController so you don't have to subclass and you can simply drop in any project and it will just work!

*Original screenshot*

<img src="https://github.com/kentnguyen/KNSemiModalViewController/blob/master/Docs/original.png?raw=true" /> . <img src="https://github.com/kentnguyen/KNSemiModalViewController/blob/master/Docs/original2.png?raw=true" />

*Replica (view demo video to see the beautiful animation)*

<img src="https://github.com/kentnguyen/KNSemiModalViewController/blob/master/Docs/ss1.png?raw=true" /> . <img src="https://github.com/kentnguyen/KNSemiModalViewController/blob/master/Docs/ss2.png?raw=true" />

*On iPad

<img src="https://github.com/kentnguyen/KNSemiModalViewController/blob/master/Docs/ss3.png?raw=true" />

### Demo

Download a demo clip [here](https://github.com/kentnguyen/KNSemiModalViewController/blob/master/Docs/KNSemiModalDemo.mov?raw=true) (1.3MB, .mov)

### Features
* Works with bare UIViewController
* Works with UIViewController contained inside UINavigationController
* Works with UIViewController contained inside UINavigationController, contained inside UITabbarController
* Auto handling of modal frame size
* Auto handling of touch area for dismissal
* Resizable after presenting so that keyboard related interactions are possible
* Easy to understand and very small code base, only 2 files
* Trivial to implement as subclass
* Landscape support (not during presentation)
* Only use basic CAAnimation
* iPad support (experimental)
* Minimum iOS 5.0 (if you need 4.x support, use older commits before Jan 2013)

### Optional parameters

- animation duration
- parent alpha
- optional push-back
- shadow opacity
- disabling the cancel action
- transition style: slide up, fade

Easily extend this to anything you would want to make configurable. Feel free to submit pull requests.

### Installation / How to use
* Copy 4 files in `Source` folder to your project
* Add `QuartzCore.framework` to your project
* `#import "UIViewController+KNSemiModal.h"` in your ViewController
* Call `[self presentSemiModalView:myView]`
* Call `[self dismissSemiModalView]` either from parent/presenting or child/presented controller

### Major contributors

- [@yangmeyer](http://twitter.com/yangmeyer)
- [@dchohfi](https://github.com/dchohfi)

### License

In short: MIT aka Buy me coffee license [![](http://kentnguyen.com/KNCoffeeButton.png)](http://bit.ly/10KC2wr)

UIViewController+KNSemiModal is licensed under MIT License
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.
add KNSemiModalTransitionStyleSlideDown option,and change animation with spring effect.
Binary file added Source/._UIViewController+KNSemiModal.h
Binary file not shown.
Binary file added Source/._UIViewController+KNSemiModal.m
Binary file not shown.
33 changes: 17 additions & 16 deletions Source/UIViewController+KNSemiModal.h
Expand Up @@ -5,7 +5,7 @@
//
@interface NSObject (YMOptionsAndDefaults)
- (void)ym_registerOptions:(NSDictionary *)options
defaults:(NSDictionary *)defaults;
defaults:(NSDictionary *)defaults;
- (id)ym_optionOrDefaultForKey:(NSString*)optionKey;
@end
//==================================================================================================
Expand Down Expand Up @@ -34,22 +34,23 @@
#define kSemiModalWasResizedNotification @"kSemiModalWasResizedNotification"

extern const struct KNSemiModalOptionKeys {
__unsafe_unretained NSString *traverseParentHierarchy; // boxed BOOL. default is YES.
__unsafe_unretained NSString *pushParentBack; // boxed BOOL. default is YES.
__unsafe_unretained NSString *animationDuration; // boxed double, in seconds. default is 0.5.
__unsafe_unretained NSString *parentAlpha; // boxed float. lower is darker. default is 0.5.
__unsafe_unretained NSString *traverseParentHierarchy; // boxed BOOL. default is YES.
__unsafe_unretained NSString *pushParentBack; // boxed BOOL. default is YES.
__unsafe_unretained NSString *animationDuration; // boxed double, in seconds. default is 0.5.
__unsafe_unretained NSString *parentAlpha; // boxed float. lower is darker. default is 0.5.
__unsafe_unretained NSString *parentScale; // boxed double default is 0.8
__unsafe_unretained NSString *shadowOpacity; // default is 0.8
__unsafe_unretained NSString *transitionStyle; // boxed NSNumber - one of the KNSemiModalTransitionStyle values.
__unsafe_unretained NSString *shadowOpacity; // default is 0.8
__unsafe_unretained NSString *transitionStyle; // boxed NSNumber - one of the KNSemiModalTransitionStyle values.
__unsafe_unretained NSString *disableCancel; // boxed BOOL. default is NO.
__unsafe_unretained NSString *backgroundView; // UIView, custom background.
} KNSemiModalOptionKeys;

NS_ENUM(NSUInteger, KNSemiModalTransitionStyle) {
KNSemiModalTransitionStyleSlideUp,
KNSemiModalTransitionStyleFadeInOut,
KNSemiModalTransitionStyleFadeIn,
KNSemiModalTransitionStyleFadeOut,
KNSemiModalTransitionStyleSlideUp,
KNSemiModalTransitionStyleSlideDown,
KNSemiModalTransitionStyleFadeInOut,
KNSemiModalTransitionStyleFadeIn,
KNSemiModalTransitionStyleFadeOut,
};

typedef void (^KNTransitionCompletionBlock)(void);
Expand All @@ -64,13 +65,13 @@ typedef void (^KNTransitionCompletionBlock)(void);
@param dismissBlock Is called when the user dismisses the semi-modal view by tapping the dimmed receiver view.
*/
-(void)presentSemiViewController:(UIViewController*)vc
withOptions:(NSDictionary*)options
completion:(KNTransitionCompletionBlock)completion
dismissBlock:(KNTransitionCompletionBlock)dismissBlock;
withOptions:(NSDictionary*)options
completion:(KNTransitionCompletionBlock)completion
dismissBlock:(KNTransitionCompletionBlock)dismissBlock;

-(void)presentSemiView:(UIView*)view
withOptions:(NSDictionary*)options
completion:(KNTransitionCompletionBlock)completion;
withOptions:(NSDictionary*)options
completion:(KNTransitionCompletionBlock)completion;

// Convenient overloading methods
-(void)presentSemiViewController:(UIViewController*)vc;
Expand Down