Skip to content

Instantly share code, notes, and snippets.

@gorenje
Created March 23, 2011 21:12
Show Gist options
  • Save gorenje/883996 to your computer and use it in GitHub Desktop.
Save gorenje/883996 to your computer and use it in GitHub Desktop.
using tntooltip with timer
@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];
if ( ![[[ConfigurationManager sharedInstance] pubProperties] showToolTips] ) {
[tooltip close];
}
return tooltip;
}
- (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