0

I am very new to IOS app dev.

I want to achieve slide In/out webview (e.g. from right), which everyone should seen one.

When user click a link, a new webview will slide in from right and load a webpage. If the user swipe right, the webview will move back to right side depends how much the distance.

To name a few apps got this function... Flipboard / Line / Facebook Groups...

Imgur Notice that the webview can be dragged by the user horizontally

I've been searching this for some time before i get my hands dirty and start the project. However, I couldn't find anything at all.

Can someone please point me to the right direction / keywords. How to setup such structure in xcode, or if there are existing controls (or default build-ins) which will do the trick...

Thanks

Samfriend
  • 55
  • 2
  • 8

2 Answers2

0

this effect is easily achieved with swifts built in segue methods. I believe it is now called show and used to be called push, but say you have the 2 views, first one contains the link or what ever and the second one is your web view. You control drag from first view to the other in your story board and create a show(push) segue. There are some snippets of code around if you go looking for this so I don't want to repeat them but the default animation slides the new view in from the right and when you swipe to the right the view is pushed out the way to review the old view.

Hope this is of some use, Dom

Dom Bryan
  • 1,238
  • 2
  • 19
  • 39
  • when swipe right on the 2nd view, can I start the touchmove from the center of the screen and the 2nd view will follow my distance (horizontially). like the common drawer controls. – Samfriend Mar 08 '15 at 02:04
  • I'm not sure about starting the swipe from the middle, I have it from the left to right and I can drag it half way, 3 quarters, 1 cm and its follows my thumb. I will have a look for you about starting the drag from the middle. – Dom Bryan Mar 08 '15 at 12:57
0

This is not default present/dismiss animation for a show action in segue or presentViewController method and it seems interactive. To implement this, you should customize your own animator class.

if you use presentViewController/dismissViewController without UINavigationController, have a look at UIViewController's transitioningDelegate

And if you use UINavigationController, have a look at UINavigationController's delegate method :

func navigationController(_ navigationController: UINavigationController, animationControllerForOperation operation: UINavigationControllerOperation, fromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning?
func navigationController(_ navigationController: UINavigationController, interactionControllerForAnimationController animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning?

I am afraid this is not easy part in IOS animation design. If you are new in the field, you can use animator classes already designed on Github.

duan
  • 8,515
  • 3
  • 48
  • 70