ProductPromotion
Logo

Swift

made by https://0x3d.site

GitHub - canalesb93/MantleModal: A draggable modal for iOS Applications.
A draggable modal for iOS Applications. Contribute to canalesb93/MantleModal development by creating an account on GitHub.
Visit Site

GitHub - canalesb93/MantleModal: A draggable modal for iOS Applications.

GitHub - canalesb93/MantleModal: A draggable modal for iOS Applications.

Mantle Modal

Draggable Modal, PopUp or Menu written in Swift.

Description

A simple modal resource that uses a UIScrollView to allow the user to close the view by removing it from the screen.

Install Instructions

CocoaPods

MantleModal is available through CocoaPods. To install it, simply add the following line to your Podfile:

use_frameworks!

target 'ProjectName' do
  pod 'MantleModal'
end

Then, run pod install

In case you haven't installed CocoaPods yet, run the following command

$ gem install cocoapods

Manual

Drag the file named RCMantleViewController.swift into your project.

Usage

Setup is faily simple, but I have plans to make it even easier later.

Step 1

Add a new View Controler into your storyboard and set the Class to RCMantleViewController and the Storyboard ID to MantleViewController.

Step 3

Import the module to your parent controller(if your using CocoaPods)

  import MantleModal

Activate the modal like this in your parent controller.

  // Create the MantleViewController from the Storyboard using the ID
  let mantleViewController = storyboard!.instantiateViewControllerWithIdentifier("MantleViewController") as! RCMantleViewController
  // Create your modal controller with your storyboard ID
  let popUpViewController = storyboard!.instantiateViewControllerWithIdentifier("YourUniqueStoryboardID") as! YourViewController
  // Set it's delegate to be able to call 'delegate.dismissView(animated: Bool)'
  popUpViewController.delegate = mantleViewController
  // Initialize Mantle
  mantleViewController.setUpScrollView()
  // Add your modal to Mantle
  mantleViewController.addToScrollViewNewController(popUpViewController)
  // Present the modal through the MantleViewController
  self.presentViewController(mantleViewController, animated: false, completion: nil)

Step 4

In your modal's controller also import:

  import MantleModal

Then define your delegate helper.

  var delegate: RCMantleViewDelegate!

And then dismiss the modal using this:

  delegate.dismissView(true)

Configuration

MantleModal currently includes some configuration which you must call before mantleViewController.setUpScrollView(). The current configuration available includes:


  // Allows you to dismiss the view by dragging up
  mantleViewController.bottomDismissible = false
  // Allows you to dismiss the view by dragging down
  mantleViewController.topDismissable = true
  // Allows you to drag to the sides to close
  mantleViewController.draggableToSides = false

  // 'appearOffset' moves the menu closer to the edge so that it appears quicker
  mantleViewController.appearOffset = CGFloat(290)
  // '290' could be the distance between the top of the popup and the top of the screen 
  
  // Makes the view present from the top, can be set multiple times before presenting
  // Also makes it hide to the top.
  mantleViewController.appearFromTop = true // // default = false

You can also access the ScrollView and modify its options, just make sure you do it after calling mantleViewController.setUpScrollView()

  mantleViewController.scrollView.bounces = false

How it works

The view you are actually presenting is actually a UIScrollView with a larger UIView inside that contains your own view along with extra empty space that is fully created by RCMantleViewController. RCMantleViewController will then detect when your view is no longer centered in the ScrollView and dismiss the complete view. It does not use native modal animations and uses the UIScrollView's scroll to content animation.

Pending

  • Orientation change support.
  • More...

Credits

Mostly done by myself - Ricardo Canales

I am still have many things to learn about iOS development so any suggestions and contributions are welcome.

Initial code inspired by this StackOverflow post. Credit to lbrendanl and Poql

More Resources
to explore the angular.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory