Giter Site home page Giter Site logo

andreamazz / ampoptip Goto Github PK

View Code? Open in Web Editor NEW
3.2K 71.0 434.0 4.14 MB

An animated popover that pops out a given frame, great for subtle UI tips and onboarding.

License: MIT License

Ruby 1.72% Swift 97.53% Objective-C 0.75%
popover poptip onboarding popup baloon

ampoptip's Introduction

👋 Hey

I'm an iOS and Web developer, currently working at Fancy Pixel and as a freelancer. I mainly work with Swift (you'll find a bunch of iOS libraries used by many in my repos), but also work a lot with React for the web. Once I close my laptop I get into my workshop for some hand tools woodworking 🔨

Get in touch

Want to collaborate on a new OSS project? Don't hesitate to contact me. I'm also available for freelance work on iOS.

✉️

ampoptip's People

Contributors

adamc01 avatar andreamazz avatar bennol avatar bpollman avatar chrisvasselli avatar coeur avatar deronbrown avatar dukandar avatar felipowsky avatar grimlock257 avatar jaimeleonparada avatar jobinsjohn avatar kevin-hirsch avatar lucaslt89 avatar melsam avatar mikhail-stepkin avatar neda20 avatar pigigaldi avatar readmecritic avatar retsohuang avatar rgomesbr avatar rivera-ernesto avatar rserentill avatar sandeepbol avatar sarsonj avatar seitk avatar simdani avatar valeriomazzeo avatar younata avatar zdavison avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ampoptip's Issues

NavigationBarItemFrame

This is super cool library, thanks for making it.

It would be awesome if you could add getting frames for navigation bar items like right navibar button frame.

Is there any way to get the frame of self.navigationItem.leftBarButtonItem at the moment? I've been trying to find out the way, but no luck yet.

Different appearance animation / custom animation

Hello @andreamazz,

I was thinking it could be great to let the user have a choice for the appearance animation, maybe via a UI_APPEARANCE_SELECTOR enum property like:

typedef NS_ENUM(NSInteger, AMPopTipAppearanceAnimation) {
    AMPopTipAppearanceAnimationScaleUp, // scale 2.0 to 1.0
    AMPopTipAppearanceAnimationScaleDown, // scale 0.3 to 1.0
    AMPopTipAppearanceAnimationFadeIn, // alpha 0 to 1
    AMPopTipAppearanceAnimationFadeInTranslate, // alpha 0 to 1 and shift from an offset to final position (translation is depending on popover direction)
    AMPopTipAppearanceAnimationNone // no animation at all
};

@property (nonatomic, assign) AMPopTipAppearanceAnimation defaultAppearanceAnimation UI_APPEARANCE_SELECTOR;

What do you think of that?


It could also provide a custom animation block for each AMPopTip instance:

@property (nonatomic, copy) void (^appearanceAnimationSetup)(void);
@property (nonatomic, copy) void (^appearanceAnimation)(void);

where a user could do something like:

popTip. appearanceAnimationSetup = ^ {
    popTip.alpha = 0;
};
popTip. appearanceAnimation = ^ {
    popTip.alpha = 1;
};

Or, we can let the user control entirely the animation by doing instead:

@property (nonatomic, copy) void (^appearanceAnimation)(void (^completion)(void));

And implementing it like:

popTip. appearanceAnimation = ^(void (^completion)(void)) {
    popTip.alpha = 0;
    [UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.6 initialSpringVelocity:1.5 options:(UIViewAnimationOptionCurveEaseInOut) animations:^{
        popTip.alpha = 1;
    } completion:completion];
}

Where he has to call back the completion so in AMPopTip code, it knows when to do after animation code.

The second idea for custom animation might be a little bit too permissive because it makes animationIn and delayIn obsolete. Also, for the custom animation, we should provide same properties but for hiding the popover.

Rounded arrow

Hi @andreamazz, thank you for your super AMPopTip! :)

What do you think of adding a property like arrowRadius to have a rounded arrow?
I would like it very much! Something like this:

screen shot 2015-05-05 at 13 49 02

Can't change position of currently displayed tip

I'm showing tooltip over a collection view cell that was pressed last. If I just call showText: on every click, tolltip opens only after the first click and does nothing on the next clicks. It would be good, if tooltip would update it's position and text when showtext: is called on the already visible tooltip.

PS. For the moment I made two tooltip objects and hide one and show second one on click, but that doesn't seem right.

Poptip arrow position

It would be really great to add feature to set position of poptip arrow (not only center, but left and right (after edge insets settings)).

AMPopTip Doesn't work with XIB created CustomView set for this PopTip, All App hangs

Hello I am building the AMPopTip with this code as mentioned , but the UI hangs if I use the XIB created custom view.

@Property (nonatomic, strong) AMPopTip *popTip1;
@Property (nonatomic, strong) CLInfoPopUpView *popUpView; //My view

//Initialised tried using local in button tape or in View did load as well :
CLInfoPopUpView * popView = [[[NSBundle mainBundle] loadNibNamed:@"CLInfoPopUpView" owner:self options:nil] lastObject];

self.popTip1 = [AMPopTip popTip];
self.popTip1.shouldDismissOnTap = YES;
self.popTip1.edgeMargin = 0;
self.popTip1.offset = 2;
self.popTip1.edgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
[self.popTip1 setBackgroundColor:[UIColor grayColor]];
[self.popTip1 setPopoverColor:[UIColor grayColor]];

The Button function of tap show this.

if ([self.popTip1 isVisible]) {
[self.popTip1 hide];

    self.popTip1 = [AMPopTip popTip];

    return;
}
    [self.popTip1 showCustomView:popView direction:AMPopTipDirectionDown inView:self.view fromFrame:cell.infoBtn.frame];

Tool tip comes first time but later app hang no operations happening. Similarly if I try using the UIview alloc init method to make the custom view as u show in Demo it work , can you help why this is happening.

tableView on popView can't respond touch.

UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 100, 200)];
tableView.delegate = self;
tableView.dataSource = self;
[tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
[customView addSubview:tableView];
[self.popTip showCustomView:customView direction:AMPopTipDirectionDown inView:self.view fromFrame:sender.frame];

When the Show customView layout cannot be used

When a XIB custom view, aotulayout can't use, for the first time show popTipView is normal, but closed again after opening will cause a suspended animation!

  • (void)layoutSubviews {
    [super layoutSubviews];
    [self setup];
    }
  • (void)setup {

}

These two methods will call cycles

  • (void)show {
    if (self.isVisible || self.isAnimating) {
    return;
    }
    self.isAnimating = YES;
    [self setNeedsLayout];
    [self performEntranceAnimation:^{
    [self.containerView addGestureRecognizer:self.tapRemoveGesture];
    [self.containerView addGestureRecognizer:self.swipeRemoveGesture];
    if (self.appearHandler) {
    self.appearHandler();
    }
    if (self.actionAnimation != AMPopTipActionAnimationNone) {
    [self startActionAnimation];
    }
    self.isVisible = YES;
    self.isAnimating = NO;
    }];
    }

    [self performEntranceAnimation:^{

}];

This method of correction will not be invoked

Make it easier to handle screen orientation change

We are using AMPopTip in an app that supports both Portrait and Landscape. When a user rotates their device while a tooltip is visible, it obviously will now point at an incorrect location.

I know that AMPopTip is just a UIView that I'm free to position myself. However, all the calculation for how to position the tooltip correctly is internal to AMPopTip and I'd rather not recreate this myself.

Would it be possible to expose a method that lets me update the "fromFrame" such that pop-tip will re-do it's setup method with that new frame? That way on rotate I can check for any AMPopTip's where isVisible is YES and I'll send a new fromFrame to them?

inBlock and delay parameters

Couple of other ideas that would be great in my situation...

inBlock parameter: a block that is executed when the poptip appears. This is the opposite of the dismissBlock.
example: I am highlighting certain UI elements when the poptip appears and would do it in this block.

delay parameter: a delay before the poptip is shown.
example: I don't want the poptip to appear right away, it is more likely to get attention after a short delay.

These are feature that I've implemented in my own view controllers but would be great if they were contained within the poptip itself.

Not able to add a tap gesture to the popover

I am trying to add a tap gesture to the popover so that when it is clicked I want to call a function which does some basic tasks. I tried this but doesn't seem to work:

self.helpTip!.userInteractionEnabled = true self.helpTip!.addGestureRecognizer(UITapGestureRecognizer(target: self, action: Selector("demo")))

Please help!

Nested Frames and UIStackView

PopTips do not play nice in Nested Frames or in UIStackViews.

The arrow points to the inside of the frame at a position that is difficult to determine beforehand.

Any ideas?

Tip either doesn't display or displays in wrong spot

Hi, I'm using this with Swift and a bridging header so that could be the reason it't not working.

I basically want the tip to appear as soon as the app is open:

    var popTip = AMPopTip()

    override func viewDidAppear(animated: Bool) {
    super.viewDidAppear(true)

    popTip.showText("If you like the quote, swipe the card to the right…otherwise swipe to the left! ", direction: AMPopTipDirection.Down, maxWidth: 260, inView: self.view, fromFrame:card1.frame)
}

Any ideas? Thanks :)

Feature: Add AMPopTipDirectionNone to center in view

Hi,

I would like to use this control centered in a view. I think you could mimic the behavior of UIPopovers by adding a AMPopTipDirectionNone direction enum value and center in the destination view frame.

Thanks for considering!

Adding a header to a popover?

Firstly, thank you for this amazing library which is really helpful. Is there a possibility of adding a header to the popover? Something like this:
screen shot 2015-09-29 at 12 01 06 pm

Use a barButtonItem as source

Is it possible to use this with a UIBarButtonItem?

leftBarButtonItem could be hacked as it will always be on the top left of the view, but what abut a rightBarButtonItem?

Add Shadows

It would be great to have an option to create shadows around the PopTip. It's an amazing repo by the way; this is just an enhancement.

Not Dimissable

Hi @andreamazz

When I add an ActionAnimation, I have to tap it a many times super fast to get it to randomly dismiss.

However, if I remove the ActionAnimation it dismisses on first tap.

PopTips on Views with scroll

When i try to use the PopTip on a Scrollable view (most in cases of 3.5") only works when the view is in the original position, when you change, the PopTip remains on that position, doesn't change even when you try to show it again...

Visible check can not be trusted

In the hide method in AMPopTip, the tip view will be removed only when finished == YES. However, finished == NO could also happen when put [myTip hide] into viewWillDisappear. So in this case, myTip.isVisible could still return YES even I have called [myTip hide].

Pop tip zero frame

Hello,

I am trying to add a pop tip to a scroll view but nothing shows up. When I look at the subviews of the scrollview the AMPopTip is there but the frame is 0. What could be causing this?

<AMPopTip: 0x7fbdfc8bfe00; frame = (0 0; 0 0); text = 'Tap to be...'; animations = { transform=<CASpringAnimation: 0x7fbdfa55a520>; }; layer = <CALayer: 0x7fbdfc8893b0>>

Thanks!
Michael

Add a dismissHandler

Hi-

Great library, thanks for your hard work!

I would really like to see a block parameter, similar to tapHandler, that would be executed when the tip is dismissed no matter if the tip was dismissed manually, by timer duration or by tap.

For example, in this block I would mark this tip as "seen" the user defaults.

PopTip Pointing at the wrong position

In ScrollView if you scroll down or up and trigger the PopTip it will point faraway from the frame it was supposed to point on. every time you change the position of the view the PopTip will point on different spot.
Thanks in advance

Slather failing

From the latest travis builds:

$ slather
Slathering...
/Users/travis/.rvm/gems/ruby-2.0.0-p481/gems/slather-1.8/lib/slather/project.rb:50:in `coverage_files': No coverage files found. Are you sure your project is setup for generating coverage files? Try `slather setup your/project.pbxproj` (StandardError)
    from /Users/travis/.rvm/gems/ruby-2.0.0-p481/gems/slather-1.8/lib/slather/coverage_service/coveralls.rb:76:in `coveralls_coverage_data'
    from /Users/travis/.rvm/gems/ruby-2.0.0-p481/gems/slather-1.8/lib/slather/coverage_service/coveralls.rb:129:in `post'
    from /Users/travis/.rvm/gems/ruby-2.0.0-p481/gems/slather-1.8/bin/slather:72:in `post'
    from /Users/travis/.rvm/gems/ruby-2.0.0-p481/gems/slather-1.8/bin/slather:40:in `execute'
    from /Users/travis/.rvm/gems/ruby-2.0.0-p481/gems/clamp-0.6.5/lib/clamp/command.rb:67:in `run'
    from /Users/travis/.rvm/gems/ruby-2.0.0-p481/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb:11:in `execute'
    from /Users/travis/.rvm/gems/ruby-2.0.0-p481/gems/clamp-0.6.5/lib/clamp/command.rb:67:in `run'
    from /Users/travis/.rvm/gems/ruby-2.0.0-p481/gems/clamp-0.6.5/lib/clamp/command.rb:132:in `run'
    from /Users/travis/.rvm/gems/ruby-2.0.0-p481/gems/clamp-0.6.5/lib/clamp.rb:6:in `Clamp'
    from /Users/travis/.rvm/gems/ruby-2.0.0-p481/gems/slather-1.8/bin/slather:6:in `<top (required)>'
    from /Users/travis/.rvm/gems/ruby-2.0.0-p481/bin/slather:23:in `load'
    from /Users/travis/.rvm/gems/ruby-2.0.0-p481/bin/slather:23:in `<main>'
    from /Users/travis/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in `eval'
    from /Users/travis/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in `<main>'

Looks like that Slather is failing even if the setup was performed (it was working before after all).

Any idea is welcome 😁

Having problems using with swift

Dropped AMProTip folder in and setup bridge header, no issues. Added this code

var popTip: AMPopTip = AMPopTip()
popTip.showText("This is a test", direction: AMPopTipDirection.Up, maxWidth: 40, inView: self.view, fromFrame: CGRect(x: 0, y: 0, width: 40, height: 20))

getting this error on compile

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_AMPopTip", referenced from:
      __TMaCSo8AMPopTip in DetailViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Problem with UICollectionView

When PopTip is used on a UICollectionViewCell area didSelectItemAtIndexPath: delegate does not get called. I believe this could be the effect of the "remove" gesture recognizer which is not required in my particular case.

Was able to fix this by adding;

- (void) setShouldDismissOnTapOutside:(BOOL)shouldDismissOnTapOutside
{
    _shouldDismissOnTapOutside = shouldDismissOnTapOutside;
    _removeGesture.enabled = shouldDismissOnTapOutside;
}

CPU 100%

tip.actionAnimation = AMPopTipActionAnimationBounce;
After pop or push the ViewControll,CPU rapidly rises to 100%
snip20150609_3

Add prebuilt binary

Adding a prebuilt binary to the tag will make it quicker for people using Carthage to use AMPopTip.
Just

carthage build --no-skip-current
carthage archive AMPopTip

and attach the created zip to the current tag :octocat:

Setting appearance properties crashes on iOS 7

The following lines are causing crashes on my iPod running iOS 7:

    AMPopTip.appearance().shouldDismissOnTap = true
    AMPopTip.appearance().shouldDismissOnTapOutside = false

The crash says:

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* Illegal property type, c for appearance setter, _installAppearanceSwizzlesForSetter:'

Strange flashing behavior

This is an EXCELLENT library. It's exactly what I needed.
Quick issue: when rapidly adding/removing pops from my view, I'll get weird flashing above the point. Is this an animation issue? Forgive my ignorance, I'm a relatively new developer :)

Keep up the good work!

ezgif com-video-to-gif

Bounce doesn't work in Swift

I've can use all PopTip functionality like this:

self.tooltip.showText(self.pocketText, direction: AMPopTipDirection.Up, maxWidth: 260, inView: self.view, fromFrame:self.navigationBar.frame)
                self.tooltip.popoverColor = greenColor

but somehow it is not possible for me to set bounce like this:

 self.tooltip.bounce = true

What am I doing wrong?
Thanks in advance :)

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.