Is there a way to implement Slide Sidebar Menu (Like Facebook app) in IOS Swift without any third party library? I look for solutions but I only founded this feature implemented in Objective-C.
I believe you can start form UISplitViewController which was drastically updated in iOS8. Watch sessions View Controller Advancements in iOS8 and Building Adaptive Apps with UIKit for details. They provide code example from second session (but not form first one :/). At this point it feels natural for me to make this kind of UI based on split view controller in iOS8.
Update: It looks like not all API they talking about are landed yet. In current beta4 mentioned in video condensesBarsOnSwipe is not presented, for example.
I think using Custom View Controller Transitions is a solid approach for making slideout menus:
Custom View Controller Transitions are difficult to learn at first (they were for me, at least). I wrote a blog post on how to create an interactive slideout menu, and tried my best to make it as easy to understand as possible.
You can also jump straight into the code on GitHub.
At a very high level, this is how it works:
UIViewControllerAnimatedTransitioning
protocol. You use a snapshot to represent the main view controller during animations.UIPercentDrivenInteractiveTransition
object to keep the transition in sync with the user's movements.UIViewControllerTransitioningDelegate
protocol and wires up all the custom animations and interactive transitions.I actually have a previous answer on this thread that uses a Scrollview / Container View. This approach is OK for a prototype, but runs into a lot of edge cases and bugs when making your app production ready. Spending every week responding to blog comments and fixing edge cases is what motivated me to write a second blog post on the subject.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With