Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ToolTips in iOS through native UI Controls?

How do I create tooltips or something similar in iOS, without using any third party classes? I have a UIButton that I'd like to have a tooltip popup for a few seconds or until it's cleared. I have seen third party classes and libraries, but want to know if natively it's supported. I also want to show an arrow popping up from where the tooltip is coming from. I've seen some UIActionSheet Popups have this arrow.

Cheers, Amit

like image 686
apollosoftware.org Avatar asked Dec 21 '22 11:12

apollosoftware.org


1 Answers

Well I ended up using the third party tooltip CMTopTipView afterall. It's relatively low overhead, just a header and implementation. Modified it slightly to account for ARC. Here is what I did:

#import "CMPopTipView.h"

CMPopTipView *navBarLeftButtonPopTipView;

- (void) dismissToolTip
{
   [navBarLeftButtonPopTipView dismissAnimated:YES];
}

- (void) showDoubleTap
{
    navBarLeftButtonPopTipView = [[CMPopTipView alloc] 
       initWithMessage:@"DOUBLE Tap \n to view details"] ;
    navBarLeftButtonPopTipView.delegate = self;
    navBarLeftButtonPopTipView.backgroundColor = [UIColor darkGrayColor];
    navBarLeftButtonPopTipView.textColor = [UIColor lightTextColor];
    navBarLeftButtonPopTipView.opaque = FALSE;
    [navBarLeftButtonPopTipView presentPointingAtView:catButton1 
        inView:self.view animated:YES];
    navBarLeftButtonPopTipView.alpha = 0.75f;

    NSTimer *timerShowToolTip = [NSTimer scheduledTimerWithTimeInterval:5.0 
     target:self 
     selector:@selector(dismissToolTip) userInfo:nil repeats:NO];

 }
like image 200
apollosoftware.org Avatar answered Jan 06 '23 07:01

apollosoftware.org