Created
March 22, 2011 16:01
-
-
Save gorenje/881469 to your computer and use it in GitHub Desktop.
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
@implementation TNToolTip (WithTimer) | |
+ (TNToolTip)toolTipWithString:(CPString)aString | |
forView:(CPView)aView | |
closeAfter:(float)aSecondsValue | |
{ | |
var tooltip = [TNToolTip toolTipWithString:aString forView:aView]; | |
var stopInvoker = [[CPInvocation alloc] initWithMethodSignature:nil]; | |
[stopInvoker setTarget:tooltip]; | |
[stopInvoker setSelector:@selector(fadeOut)]; | |
[CPTimer scheduledTimerWithTimeInterval:aSecondsValue | |
invocation:stopInvoker | |
repeats:NO]; | |
return tooltip; | |
} | |
/* Taken from https://gist.github.com/881521 */ | |
- (void)fadeOut | |
{ | |
var thisDict = [CPDictionary dictionaryWithObjects:[self, CPViewAnimationFadeOutEffect] | |
forKeys:[CPViewAnimationTargetKey, | |
CPViewAnimationEffectKey]]; | |
var animation = [[CPViewAnimation alloc] initWithViewAnimations:[thisDict]]; | |
[animation setDuration:1.0]; | |
[animation setDelegate:self]; | |
[animation startAnimation]; | |
} | |
- (void)animationDidEnd:(id)sender | |
{ | |
[self close]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment