ZLSwipeableView icon indicating copy to clipboard operation
ZLSwipeableView copied to clipboard

How can I add a swipe hint?

Open oferRounds opened this issue 9 years ago • 12 comments

I'm using the the class in my on boarding. I'd like to add hint, with delicate card move to hint the user that the view is he's currently seeing is swipeable.

Anyone has an idea how can I achieve this? I'd like the change to appear "real", as if someone really did a little swipe to the right, and then removed his finger.

oferRounds avatar Jun 18 '16 06:06 oferRounds

@zhxnlai - I tried to use UIView animateWithDuration, but was not able to achieve an effect which looked real.

Any idea maybe?

oferRounds avatar Jun 18 '16 06:06 oferRounds

How about animating the anchorView?

zhxnlai avatar Jun 18 '16 07:06 zhxnlai

Thanks! What does the anchorView represent?

oferRounds avatar Jun 18 '16 07:06 oferRounds

It is a special view used to animate the card with physics

zhxnlai avatar Jun 18 '16 08:06 zhxnlai

Ok, so you what you have in mind is to use UIView's animateWithDuration and just set a new location to it? And what will be the best way to make it go back to it's origin (as if the user removed his finger)?

oferRounds avatar Jun 18 '16 08:06 oferRounds

After the user places his/her finger on the cardView, the library will start to animate the cardView based on anchorView's location. In this case, just animate the anchorView and the cardView will follow it.

zhxnlai avatar Jun 18 '16 08:06 zhxnlai

Ok, got you. Two more questions please:

  1. Does it also consider his transform state? I'd like to give a delicate twist.
  2. And how will I mimic the finger removal - snapping back the view to its origin?

oferRounds avatar Jun 18 '16 08:06 oferRounds

  1. Only the position of anchorView is used
  2. Do you have access to ViewManager class? If so you can call setStateSnapping to mimic finger removal

zhxnlai avatar Jun 18 '16 09:06 zhxnlai

  1. Then what will be the best way to animate a delicate rotation?
  2. Sounds good - I do have

oferRounds avatar Jun 18 '16 09:06 oferRounds

Did a very preliminary test of changing the location of the top view via the anchorView, but it does not move... This is the code I use:

-(void)showHint
{
    ViewManager *viewManager = [self managerForView:self.topView];
    UIView *anchorView = viewManager.anchorView;

    anchorView.center = CGPointMake(anchorView.center.x + 15.0, anchorView.center.y + 15.0);
} 

oferRounds avatar Jun 18 '16 11:06 oferRounds

I tried also another approach: Passing an array of movement values (which I recorded earlier when testing a slight hint) to a method which I added, which is similar to the gesture handler method. This method handles these values (the first value is treated as the began, the last as the end and all the others - as changed), but it didn't really work - the top card did not move...

oferRounds avatar Jun 19 '16 06:06 oferRounds

@zhxnlai - any chance you can have a look at my trials here?

oferRounds avatar Jun 29 '16 14:06 oferRounds