Git Product home page Git Product logo

sexytooltip's Introduction

SexyTooltip

The tooltip that has all the right moves.

It handles the gross complexity of view hierarchies and scroll view offsets. You just tell it which view to point at it'll do the rest! It'll even follow that view around the screen as it moves, re-shifting itself and its arrow to stay within the bounds of the window (or another superview you specify). Highly configurable yet super simple out-of-the-box.

It's pretty sexy.

facebook example motion example

Installation

Add pod 'SexyTooltip' to your Podfile or download the source here

Creation

The default initializer is to give the tooltip a content view which will be contained within the tooltip.

SexyTooltip *errorTooltip = [[SexyTooltip alloc] initWithContentView:self.errorLabel];

SexyTooltip can also be created with an NSAttributedString, which will create a UILabel as the tooltip's content view.

SexyTooltip *greetingsTooltip = [[SexyTooltip alloc] initWithAttributedString:greetingsText
                                                                sizedToView:self.view
                                                                withPadding:UIEdgeInsetsMake(10, 5, 10, 5)
                                                                  andMargin:UIEdgeInsetsMake(20, 20, 20, 20)];
[self.view addSubview:greetingsTooltip];

Presentation

The true beauty of SexyTooltip shines once you present it. No more dealing with nested CGRect logic and UIScrollView offsets. Just pass the view that you want the tooltip to point at, and even as that view moves around the SexyTooltip will continue pointing at the fromView (see the example video above)

[greetingsTooltip presentFromView:self.loginButton
                           inView:self.view
                       withMargin:10
                         animated:YES];

You can also present from a rect or point.

Dismissal

Dismissal is as easy as calling -(void)dismiss; which defaults to animated dismissal. There's always [self.tooltip dismissAnimated:NO]; if you want to suck all of the joy out of your app ;)

Additionally, you can do [self.tooltip dismissInTimeInterval:10]; if you'd like to keep 'er showing for 10 seconds. Any other dismissals will cancel this timer, or you can do so yourself with [self.tooltip cancelDismissTimer];

Your tooltip will also be dismissed when it is tapped.

Appearance

The default is a nice sexy white with a subtle shadow and curved corners. You can change everything from hasShadow to arrowMargin to borderColor to padding to arrowHeight etc. All of these methods will maintain where your tooltip is currently pointing if they're called while it's showing.

Arrow direction

You can specify an array of permittedArrowDirections which specify the preference order of pointing directions. The tooltip will attempt to fit itself inside the inView you passed while maintaining the arrow pointing at the target view or point. For example, if you're pointing at a view that's moving around the screen, SexyTooltip will continue to be visible as the view moves to the edges by changing its direction in order to stay within the bounds of the inView. This is very powerful for complex tooltip scenarios or cases where you're not sure how the interface might look at the moment of presentation (e.g. variable text sizes)

typedef NS_ENUM(NSUInteger, SexyTooltipArrowDirection) {
    SexyTooltipArrowDirectionUp,
    SexyTooltipArrowDirectionDown,
    SexyTooltipArrowDirectionLeft,
    SexyTooltipArrowDirectionRight
};

Delegate

You can optionally hear about any of the following events as the delegate of your tooltip

@protocol SexyTooltipDelegate <NSObject>

@optional
- (void)tooltipDidPresent:(SexyTooltip *)tooltip;
- (void)tooltipDidDismiss:(SexyTooltip *)tooltip;
- (void)tooltipWillBeTapped:(SexyTooltip *)tooltip;
- (void)tooltipWasTapped:(SexyTooltip *)tooltip;

@end

Third Party Bindings

React Native

You may now use this library with React Native via the module here

sexytooltip's People

Contributors

21echoes avatar ammarahm-ed avatar clankins avatar dtrenz avatar prscx avatar tsheaff avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.