- 共通テーマ:
- Objective-C テーマに参加中!
UIView+Effect.h
// // UIView+Effect.h // KeitaiEmuPro // // Created by あんのたん on 2009/04/11. // Copyright 2009 あんのたん. All rights reserved. // #import <Foundation/Foundation.h> @interface UIView (Effect) - (void)fadeInWithDuration:(NSTimeInterval)interval; - (void)fadeOutWithDuration:(NSTimeInterval)interval; @end
UIView+Effect.m
//
// UIWindow+Effect.m
// KeitaiEmuPro
//
// Created by あんのたん on 2009/04/11.
// Copyright 2009 あんのたん. All rights reserved.
//
#import "UIView+Effect.h"
@implementation UIView (Effect)
- (void)fadeInWithDuration:(NSTimeInterval)interval {
CGFloat afterAlpha = self.alpha;
self.alpha = (CGFloat)0.0;
self.hidden = NO;
[UIView beginAnimations:@"UIWindow_FadeIn" context:nil];
[UIView setAnimationDuration:interval];
self.alpha = afterAlpha;
[UIView commitAnimations];
}
- (void)fadeOutWithDuration:(NSTimeInterval)interval {
CGFloat* context = (CGFloat *)malloc(sizeof(CGFloat));
*context = self.alpha;
[UIView beginAnimations:@"UIWindow_FadeOut" context:context];
[UIView setAnimationDidStopSelector:@selector(fadeOutDidStop:finished:context:)];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:interval];
self.alpha = (CGFloat)0.0;
[UIView commitAnimations];
}
- (void)fadeOutDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
self.hidden = YES;
self.alpha = *(CGFloat *)context;
free(context);
}
@end









