Skip to content

Instantly share code, notes, and snippets.

@satoshin2071
Last active December 28, 2015 23:18
Show Gist options
  • Save satoshin2071/7577476 to your computer and use it in GitHub Desktop.
Save satoshin2071/7577476 to your computer and use it in GitHub Desktop.
[ObjC][Sample]UIViewアニメーションでフェードイン/フェードアウト
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
@interface UIView (FadeAnimation)
- (void)fadeIn;
- (void)fadeOut;
@end
#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