Last active
December 28, 2015 23:18
-
-
Save satoshin2071/7577476 to your computer and use it in GitHub Desktop.
[ObjC][Sample]UIViewアニメーションでフェードイン/フェードアウト
This file contains hidden or 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
#import <UIKit/UIKit.h> | |
#import <QuartzCore/QuartzCore.h> | |
@interface UIView (FadeAnimation) | |
- (void)fadeIn; | |
- (void)fadeOut; | |
@end |
This file contains hidden or 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
#import "UIView+FadeAnimation.h" | |
@implementation UIView (FadeAnimation) | |
- (void)fadeIn | |
{ | |
self.alpha = 0; | |
CGRect tempFrame = self.frame; | |
self.frame = CGRectOffset(self.frame, 0, 10); | |
[UIView beginAnimations:@"fadeIn" context:nil]; | |
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; | |
[UIView setAnimationDuration:1.0]; | |
self.alpha = 1; | |
self.frame = tempFrame; | |
[UIView commitAnimations]; | |
} | |
- (void)fadeOut | |
{ | |
[UIView beginAnimations:@"fadeOut" context:nil]; | |
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; | |
[UIView setAnimationDuration:0.8]; | |
self.frame = CGRectOffset(self.frame, 0, 5); | |
self.alpha = 0; | |
[UIView commitAnimations]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment