-
Notifications
You must be signed in to change notification settings - Fork 7
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
0 parents
commit b7e33bb
Showing
18 changed files
with
903 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,26 @@ | ||
// | ||
// Created by Florian on 21/04/14. | ||
// | ||
// To change the template use AppCode | Preferences | File Templates. | ||
// | ||
|
||
|
||
#import <Foundation/Foundation.h> | ||
|
||
|
||
@class DraggableView; | ||
|
||
|
||
@protocol DraggableViewDelegate | ||
|
||
- (void)draggableView:(DraggableView *)view draggingEndedWithVelocity:(CGPoint)velocity; | ||
- (void)draggableViewBeganDragging:(DraggableView *)view; | ||
|
||
@end | ||
|
||
|
||
@interface DraggableView : UIView | ||
|
||
@property (nonatomic, weak) id <DraggableViewDelegate> delegate; | ||
|
||
@end |
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 @@ | ||
// | ||
// Created by Florian on 21/04/14. | ||
// | ||
// To change the template use AppCode | Preferences | File Templates. | ||
// | ||
|
||
|
||
#import "DraggableView.h" | ||
|
||
@implementation DraggableView | ||
|
||
- (id)initWithFrame:(CGRect)frame | ||
{ | ||
self = [super initWithFrame:frame]; | ||
if (self) { | ||
[self setup]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)setup | ||
{ | ||
UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(didPan:)]; | ||
[self addGestureRecognizer:recognizer]; | ||
self.layer.cornerRadius = 6; | ||
} | ||
|
||
- (void)didPan:(UIPanGestureRecognizer *)recognizer | ||
{ | ||
CGPoint point = [recognizer translationInView:self.superview]; | ||
self.center = CGPointMake(self.center.x, self.center.y + point.y); | ||
[recognizer setTranslation:CGPointZero inView:self.superview]; | ||
if (recognizer.state == UIGestureRecognizerStateEnded) { | ||
CGPoint velocity = [recognizer velocityInView:self.superview]; | ||
velocity.x = 0; | ||
[self.delegate draggableView:self draggingEndedWithVelocity:velocity]; | ||
} else if (recognizer.state == UIGestureRecognizerStateBegan) { | ||
[self.delegate draggableViewBeganDragging:self]; | ||
} | ||
} | ||
|
||
@end |
23 changes: 23 additions & 0 deletions
23
InteractiveAnimations/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
InteractiveAnimations/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" | ||
} | ||
} |
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,38 @@ | ||
<?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.unsignedinteger.${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> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
</dict> | ||
</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,16 @@ | ||
// | ||
// Prefix header | ||
// | ||
// The contents of this file are implicitly included at the beginning of every source file. | ||
// | ||
|
||
#import <Availability.h> | ||
|
||
#ifndef __IPHONE_5_0 | ||
#warning "This project uses features only available in iOS SDK 5.0 and later." | ||
#endif | ||
|
||
#ifdef __OBJC__ | ||
#import <UIKit/UIKit.h> | ||
#import <Foundation/Foundation.h> | ||
#endif |
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 @@ | ||
// | ||
// UINTAppDelegate.h | ||
// InteractiveAnimations | ||
// | ||
// Created by Chris Eidhof on 02.05.14. | ||
// Copyright (c) 2014 Unsigned Integer. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface UINTAppDelegate : UIResponder <UIApplicationDelegate> | ||
|
||
@property (strong, nonatomic) UIWindow *window; | ||
|
||
@end |
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 @@ | ||
// | ||
// UINTAppDelegate.m | ||
// InteractiveAnimations | ||
// | ||
// Created by Chris Eidhof on 02.05.14. | ||
// Copyright (c) 2014 Unsigned Integer. All rights reserved. | ||
// | ||
|
||
#import "UINTAppDelegate.h" | ||
#import "UINTViewController.h" | ||
|
||
@implementation UINTAppDelegate | ||
|
||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | ||
{ | ||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | ||
UINTViewController *viewController = [[UINTViewController alloc] init]; | ||
self.window.rootViewController = viewController; | ||
[self.window makeKeyAndVisible]; | ||
return YES; | ||
} | ||
|
||
@end |
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,18 @@ | ||
// | ||
// UINTViewController.h | ||
// InteractiveAnimations | ||
// | ||
// Created by Chris Eidhof on 02.05.14. | ||
// Copyright (c) 2014 Unsigned Integer. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@class UINTAnimator; | ||
@class UINTSpringAnimation; | ||
@class POPSpringAnimation; | ||
|
||
|
||
@interface UINTViewController : UIViewController | ||
|
||
@end |
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,86 @@ | ||
// | ||
// UINTViewController.m | ||
// InteractiveAnimations | ||
// | ||
// Created by Chris Eidhof on 02.05.14. | ||
// Copyright (c) 2014 Unsigned Integer. All rights reserved. | ||
// | ||
|
||
#import "UINTViewController.h" | ||
#import "DraggableView.h" | ||
#import "POPSpringAnimation.h" | ||
|
||
|
||
typedef NS_ENUM(NSInteger, PaneState) { | ||
PaneStateOpen, | ||
PaneStateClosed, | ||
}; | ||
|
||
@interface UINTViewController () <DraggableViewDelegate> | ||
|
||
@property (nonatomic) PaneState paneState; | ||
@property (nonatomic, strong) DraggableView *pane; | ||
@property (nonatomic, strong) POPSpringAnimation *animation; | ||
@end | ||
|
||
@implementation UINTViewController | ||
|
||
- (void)viewDidLoad | ||
{ | ||
[super viewDidLoad]; | ||
self.view.backgroundColor = [UIColor whiteColor]; | ||
|
||
CGSize size = self.view.bounds.size; | ||
self.paneState = PaneStateClosed; | ||
DraggableView *view = [[DraggableView alloc] initWithFrame:CGRectMake(0, size.height * .75, size.width, size.height)]; | ||
view.backgroundColor = [UIColor grayColor]; | ||
view.delegate = self; | ||
[self.view addSubview:view]; | ||
self.pane = view; | ||
|
||
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTap:)]; | ||
[self.view addGestureRecognizer:tapRecognizer]; | ||
} | ||
|
||
- (CGPoint)targetPoint | ||
{ | ||
CGSize size = self.view.bounds.size; | ||
return self.paneState == PaneStateClosed > 0 ? CGPointMake(size.width/2, size.height * 1.25) : CGPointMake(size.width/2, size.height/2 + 50); | ||
} | ||
|
||
- (void)animatePaneWithInitialVelocity:(CGPoint)initialVelocity | ||
{ | ||
[self.pane pop_removeAllAnimations]; | ||
POPSpringAnimation *animation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter]; | ||
animation.velocity = [NSValue valueWithCGPoint:initialVelocity]; | ||
animation.toValue = [NSValue valueWithCGPoint:self.targetPoint]; | ||
animation.springSpeed = 15; | ||
animation.springBounciness = 6; | ||
[self.pane pop_addAnimation:animation forKey:@"animation"]; | ||
self.animation = animation; | ||
} | ||
|
||
|
||
#pragma mark DraggableViewDelegate | ||
|
||
- (void)draggableView:(DraggableView *)view draggingEndedWithVelocity:(CGPoint)velocity | ||
{ | ||
self.paneState = velocity.y >= 0 ? PaneStateClosed : PaneStateOpen; | ||
[self animatePaneWithInitialVelocity:velocity]; | ||
} | ||
|
||
- (void)draggableViewBeganDragging:(DraggableView *)view | ||
{ | ||
[view.layer pop_removeAllAnimations]; | ||
} | ||
|
||
|
||
#pragma mark Actions | ||
|
||
- (void)didTap:(UITapGestureRecognizer *)tapRecognizer | ||
{ | ||
self.paneState = self.paneState == PaneStateOpen ? PaneStateClosed : PaneStateOpen; | ||
[self animatePaneWithInitialVelocity:[self.animation.velocity CGPointValue]]; | ||
} | ||
|
||
@end |
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,2 @@ | ||
/* Localized versions of Info.plist keys */ | ||
|
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,18 @@ | ||
// | ||
// main.m | ||
// InteractiveAnimations | ||
// | ||
// Created by Chris Eidhof on 02.05.14. | ||
// Copyright (c) 2014 Unsigned Integer. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
#import "UINTAppDelegate.h" | ||
|
||
int main(int argc, char * argv[]) | ||
{ | ||
@autoreleasepool { | ||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([UINTAppDelegate class])); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
InteractiveAnimationsTests/InteractiveAnimationsTests-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,22 @@ | ||
<?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>CFBundleExecutable</key> | ||
<string>${EXECUTABLE_NAME}</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.unsignedinteger.${PRODUCT_NAME:rfc1034identifier}</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundlePackageType</key> | ||
<string>BNDL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
</dict> | ||
</plist> |
Oops, something went wrong.