-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4dc9246
commit 92342d6
Showing
38 changed files
with
2,071 additions
and
0 deletions.
There are no files selected for viewing
484 changes: 484 additions & 0 deletions
484
...r-transitions/InteractiveTransitions-starting/SimpleTransitions.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
...ew-controller-transitions/InteractiveTransitions-starting/SimpleTransitions/AppDelegate.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// AppDelegate.h | ||
// SimpleTransitions | ||
// | ||
// Created by ben on 9/14/13. | ||
// Copyright (c) 2013 Fickle Bits. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface AppDelegate : UIResponder <UIApplicationDelegate> | ||
|
||
@property (strong, nonatomic) UIWindow *window; | ||
|
||
@end |
42 changes: 42 additions & 0 deletions
42
...ew-controller-transitions/InteractiveTransitions-starting/SimpleTransitions/AppDelegate.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// AppDelegate.m | ||
// SimpleTransitions | ||
// | ||
// Created by ben on 9/14/13. | ||
// Copyright (c) 2013 Fickle Bits. All rights reserved. | ||
// | ||
|
||
#import "AppDelegate.h" | ||
#import "TransitionListViewController.h" | ||
|
||
@implementation AppDelegate | ||
|
||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | ||
{ | ||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | ||
|
||
TransitionListViewController *transitionVC = [[TransitionListViewController alloc] init]; | ||
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:transitionVC]; | ||
self.window.rootViewController = nav; | ||
|
||
self.window.backgroundColor = [UIColor whiteColor]; | ||
[self.window makeKeyAndVisible]; | ||
return YES; | ||
} | ||
|
||
- (void)applicationWillResignActive:(UIApplication *)application { | ||
} | ||
|
||
- (void)applicationDidEnterBackground:(UIApplication *)application { | ||
} | ||
|
||
- (void)applicationWillEnterForeground:(UIApplication *)application { | ||
} | ||
|
||
- (void)applicationDidBecomeActive:(UIApplication *)application { | ||
} | ||
|
||
- (void)applicationWillTerminate:(UIApplication *)application { | ||
} | ||
|
||
@end |
15 changes: 15 additions & 0 deletions
15
...oller-transitions/InteractiveTransitions-starting/SimpleTransitions/ColorViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// ColorViewController.h | ||
// SimpleTransitions | ||
// | ||
// Created by ben on 9/15/13. | ||
// Copyright (c) 2013 Fickle Bits. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface ColorViewController : UIViewController | ||
|
||
- (id)initWithColor:(UIColor *)color; | ||
|
||
@end |
68 changes: 68 additions & 0 deletions
68
...oller-transitions/InteractiveTransitions-starting/SimpleTransitions/ColorViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// ColorViewController.m | ||
// SimpleTransitions | ||
// | ||
// Created by ben on 9/15/13. | ||
// Copyright (c) 2013 Fickle Bits. All rights reserved. | ||
// | ||
|
||
#import "ColorViewController.h" | ||
|
||
@interface ColorViewController () | ||
@property (nonatomic, strong) UIColor *color; | ||
@end | ||
|
||
@implementation ColorViewController | ||
|
||
- (id)initWithColor:(UIColor *)color { | ||
self = [super init]; | ||
if (self) { | ||
self.color = color; | ||
self.modalPresentationStyle = UIModalPresentationCustom; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
self.view.backgroundColor = self.color; | ||
self.view.layer.borderColor = [[UIColor blackColor] CGColor]; | ||
self.view.layer.borderWidth = 1.0; | ||
|
||
UIButton *dismissButton = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
dismissButton.tintColor = [UIColor blueColor]; | ||
[dismissButton setTitle:@"Back" forState:UIControlStateNormal]; | ||
|
||
[self.view addSubview:dismissButton]; | ||
dismissButton.frame = CGRectMake(0, self.view.frame.size.height - 50, self.view.frame.size.width, 50); | ||
dismissButton.backgroundColor = [UIColor whiteColor]; | ||
[dismissButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; | ||
[dismissButton addTarget:self action:@selector(dismiss:) forControlEvents:UIControlEventTouchUpInside]; | ||
|
||
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap:)]; | ||
[self.view addGestureRecognizer:tapRecognizer]; | ||
} | ||
|
||
- (UIColor *)randomColor { | ||
return [UIColor colorWithRed:(arc4random() % 255) / 255.0 | ||
green:(arc4random() % 255) / 255.0 | ||
blue:(arc4random() % 255) / 255.0 | ||
alpha:1.0]; | ||
} | ||
|
||
- (void)onTap:(id)sender { | ||
ColorViewController *nextColor = [[ColorViewController alloc] initWithColor:[self randomColor]]; | ||
nextColor.transitioningDelegate = self.transitioningDelegate; | ||
[self presentViewController:nextColor animated:YES completion:nil]; | ||
} | ||
|
||
- (void)dismiss:(id)sender { | ||
[self dismissViewControllerAnimated:YES completion:nil]; | ||
} | ||
|
||
- (void)viewWillAppear:(BOOL)animated { | ||
[super viewWillAppear:animated]; | ||
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES]; | ||
} | ||
|
||
@end |
23 changes: 23 additions & 0 deletions
23
...veTransitions-starting/SimpleTransitions/Images.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "29x29", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "40x40", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "60x60", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...nsitions-starting/SimpleTransitions/Images.xcassets/LaunchImage.launchimage/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"orientation" : "portrait", | ||
"idiom" : "iphone", | ||
"extent" : "full-screen", | ||
"minimum-system-version" : "7.0", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"orientation" : "portrait", | ||
"idiom" : "iphone", | ||
"subtype" : "retina4", | ||
"extent" : "full-screen", | ||
"minimum-system-version" : "7.0", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...ransitions/InteractiveTransitions-starting/SimpleTransitions/SimpleTransitions-Info.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>${PRODUCT_NAME}</string> | ||
<key>CFBundleExecutable</key> | ||
<string>${EXECUTABLE_NAME}</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.ficklebits.${PRODUCT_NAME:rfc1034identifier}</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>${PRODUCT_NAME}</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1.0</string> | ||
<key>LSRequiresIPhoneOS</key> | ||
<true/> | ||
<key>UIRequiredDeviceCapabilities</key> | ||
<array> | ||
<string>armv7</string> | ||
</array> | ||
<key>UISupportedInterfaceOrientations</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
</array> | ||
</dict> | ||
</plist> |
16 changes: 16 additions & 0 deletions
16
...ransitions/InteractiveTransitions-starting/SimpleTransitions/SimpleTransitions-Prefix.pch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// Prefix header | ||
// | ||
// The contents of this file are implicitly included at the beginning of every source file. | ||
// | ||
|
||
#import <Availability.h> | ||
|
||
#ifndef __IPHONE_3_0 | ||
#warning "This project uses features only available in iOS SDK 3.0 and later." | ||
#endif | ||
|
||
#ifdef __OBJC__ | ||
#import <UIKit/UIKit.h> | ||
#import <Foundation/Foundation.h> | ||
#endif |
20 changes: 20 additions & 0 deletions
20
...ntroller-transitions/InteractiveTransitions-starting/SimpleTransitions/SwatchTransition.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// SwatchTransition.h | ||
// SimpleTransitions | ||
// | ||
// Created by ben on 9/15/13. | ||
// Copyright (c) 2013 Fickle Bits. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
typedef NS_ENUM(NSInteger, SwatchTransitionMode){ | ||
SwatchTransitionModePresent = 0, | ||
SwatchTransitionModeDismiss | ||
}; | ||
|
||
@interface SwatchTransition : NSObject <UIViewControllerAnimatedTransitioning> | ||
|
||
@property (nonatomic, assign) SwatchTransitionMode mode; | ||
|
||
@end |
58 changes: 58 additions & 0 deletions
58
...ntroller-transitions/InteractiveTransitions-starting/SimpleTransitions/SwatchTransition.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// SwatchTransition.m | ||
// SimpleTransitions | ||
// | ||
// Created by ben on 9/15/13. | ||
// Copyright (c) 2013 Fickle Bits. All rights reserved. | ||
// | ||
|
||
#import "SwatchTransition.h" | ||
const CGFloat SWATCH_PRESENT_DURATION = 1.5; | ||
const CGFloat SWATCH_DISMISS_DURATION = 0.25; | ||
|
||
@implementation SwatchTransition | ||
|
||
- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext { | ||
return self.mode == SwatchTransitionModePresent ? SWATCH_PRESENT_DURATION : SWATCH_DISMISS_DURATION; | ||
} | ||
|
||
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext { | ||
UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; | ||
UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; | ||
|
||
CGRect sourceRect = [transitionContext initialFrameForViewController:fromVC]; | ||
|
||
CGAffineTransform rotation = CGAffineTransformMakeRotation(- M_PI / 2); | ||
UIView *container = [transitionContext containerView]; | ||
|
||
if (self.mode == SwatchTransitionModePresent) { | ||
[container addSubview:toVC.view]; | ||
|
||
toVC.view.layer.anchorPoint = CGPointZero; | ||
toVC.view.frame = sourceRect; | ||
toVC.view.transform = rotation; | ||
|
||
[UIView animateWithDuration:SWATCH_PRESENT_DURATION | ||
delay:0 | ||
usingSpringWithDamping:0.25 | ||
initialSpringVelocity:3 | ||
options:UIViewAnimationOptionCurveEaseIn | ||
animations:^{ | ||
toVC.view.transform = CGAffineTransformIdentity; | ||
} completion:^(BOOL finished) { | ||
[transitionContext completeTransition:YES]; | ||
}]; | ||
} else if(self.mode == SwatchTransitionModeDismiss) { | ||
[UIView animateWithDuration:SWATCH_DISMISS_DURATION | ||
delay:0 | ||
options:UIViewAnimationOptionCurveEaseIn | ||
animations:^{ | ||
fromVC.view.transform = rotation; | ||
} completion:^(BOOL finished) { | ||
[fromVC.view removeFromSuperview]; | ||
[transitionContext completeTransition:YES]; | ||
}]; | ||
} | ||
} | ||
|
||
@end |
13 changes: 13 additions & 0 deletions
13
...nsitions/InteractiveTransitions-starting/SimpleTransitions/TransitionListViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// TransitionListViewController.h | ||
// SimpleTransitions | ||
// | ||
// Created by ben on 9/14/13. | ||
// Copyright (c) 2013 Fickle Bits. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface TransitionListViewController : UITableViewController | ||
|
||
@end |
Oops, something went wrong.