Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added support for animating a view relative to super view

  • Loading branch information...
commit 8da43a7e4bcc89858be556b5fbc9e5c9060912f5 1 parent 33fc2a0
@coreyfloyd coreyfloyd authored
View
19 Classes/FTAnimation+UIView.m
@@ -102,6 +102,25 @@ - (void)backInFrom:(FTAnimationDirection)direction withFade:(BOOL)fade duration:
}
#pragma mark -
+
+- (void)backOutTo:(FTAnimationDirection)direction inView:(UIView*)enclosingView withFade:(BOOL)fade duration:(NSTimeInterval)duration delegate:(id)delegate
+ startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector {
+ CAAnimation *backOutAnim = [[FTAnimationManager sharedManager] backOutAnimationFor:self withFade:fade direction:direction inView:enclosingView
+ duration:duration delegate:delegate
+ startSelector:startSelector stopSelector:stopSelector];
+ [self.layer addAnimation:backOutAnim forKey:kFTAnimationBackOut];
+}
+
+- (void)backInFrom:(FTAnimationDirection)direction inView:(UIView*)enclosingView withFade:(BOOL)fade duration:(NSTimeInterval)duration delegate:(id)delegate
+ startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector {
+ CAAnimation *backInAnim = [[FTAnimationManager sharedManager] backInAnimationFor:self withFade:fade direction:direction inView:enclosingView
+ duration:duration delegate:delegate
+ startSelector:startSelector stopSelector:stopSelector];
+ [self.layer addAnimation:backInAnim forKey:kFTAnimationBackIn];
+}
+
+
+#pragma mark -
#pragma mark Fade Animations
- (void)fadeIn:(NSTimeInterval)duration delegate:(id)delegate startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector {
View
7 Examples/BackInOut.m
@@ -37,9 +37,12 @@ - (void)viewDidLoad {
- (void)performAnimation:(id)sender {
if(self.viewToAnimate.hidden) {
- [self.viewToAnimate backInFrom:self.directionControl.selectedSegmentIndex+4 withFade:NO duration:.4 delegate:nil];
+ //[self.viewToAnimate backInFrom:self.directionControl.selectedSegmentIndex+4 withFade:NO duration:.4 delegate:nil];
+ [self.viewToAnimate backInFrom:self.directionControl.selectedSegmentIndex+4 inView:self.viewToAnimate.superview withFade:NO duration:0.4 delegate:nil startSelector:nil stopSelector:nil];
} else {
- [self.viewToAnimate backOutTo:self.directionControl.selectedSegmentIndex+4 withFade:NO duration:.4 delegate:nil];
+ //[self.viewToAnimate backOutTo:self.directionControl.selectedSegmentIndex+4 withFade:NO duration:.4 delegate:nil];
+ [self.viewToAnimate backOutTo:self.directionControl.selectedSegmentIndex+4 inView:self.viewToAnimate.superview withFade:NO duration:0.4 delegate:nil startSelector:nil stopSelector:nil];
+
}
}
View
12 Headers/FTUtils/FTAnimation+UIView.h
@@ -33,6 +33,12 @@
- (void)slideOutTo:(FTAnimationDirection)direction duration:(NSTimeInterval)duration delegate:(id)delegate
startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
+//use the enclosing view
+- (void)slideInFrom:(FTAnimationDirection)direction inView:(UIView*)enclosingView duration:(NSTimeInterval)duration delegate:(id)delegate
+ startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
+- (void)slideOutTo:(FTAnimationDirection)direction inView:(UIView*)enclosingView duration:(NSTimeInterval)duration
+ delegate:(id)delegate startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
+
- (void)backOutTo:(FTAnimationDirection)direction withFade:(BOOL)fade duration:(NSTimeInterval)duration delegate:(id)delegate;
- (void)backOutTo:(FTAnimationDirection)direction withFade:(BOOL)fade duration:(NSTimeInterval)duration delegate:(id)delegate
startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
@@ -40,6 +46,12 @@
- (void)backInFrom:(FTAnimationDirection)direction withFade:(BOOL)fade duration:(NSTimeInterval)duration delegate:(id)delegate
startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
+//Use the enclosing view
+- (void)backOutTo:(FTAnimationDirection)direction inView:(UIView*)enclosingView withFade:(BOOL)fade duration:(NSTimeInterval)duration delegate:(id)delegate
+ startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
+- (void)backInFrom:(FTAnimationDirection)direction inView:(UIView*)enclosingView withFade:(BOOL)fade duration:(NSTimeInterval)duration delegate:(id)delegate
+ startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
+
- (void)fadeIn:(NSTimeInterval)duration delegate:(id)delegate;
- (void)fadeIn:(NSTimeInterval)duration delegate:(id)delegate startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
- (void)fadeOut:(NSTimeInterval)duration delegate:(id)delegate;
View
7 Headers/FTUtils/FTAnimationManager.h
@@ -178,6 +178,13 @@ static inline CGPoint FTAnimationOffscreenCenterPoint(CGRect viewFrame, CGPoint
duration:(NSTimeInterval)duration delegate:(id)delegate
startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
+- (CAAnimation *)backOutAnimationFor:(UIView *)view withFade:(BOOL)fade direction:(FTAnimationDirection)direction inView:(UIView*)enclosingView
+ duration:(NSTimeInterval)duration delegate:(id)delegate
+ startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
+- (CAAnimation *)backInAnimationFor:(UIView *)view withFade:(BOOL)fade direction:(FTAnimationDirection)direction inView:(UIView*)enclosingView
+ duration:(NSTimeInterval)duration delegate:(id)delegate
+ startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
+
- (CAAnimation *)fadeAnimationFor:(UIView *)view duration:(NSTimeInterval)duration
delegate:(id)delegate startSelector:(SEL)startSelector
stopSelector:(SEL)stopSelector fadeOut:(BOOL)fadeOut;
Please sign in to comment.
Something went wrong with that request. Please try again.