A draggable modal for iOS Applications.

Related tags

UI MantleModal
Overview

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 2 Add your own view into your storyboard which will represent the modal. Also set a unique **Storyboard ID** to it.
If you are gonna use a PopUp set the background view color transparent.

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

You might also like...
BulletinBoard is an iOS library that generates and manages contextual cards displayed at the bottom of the screen
BulletinBoard is an iOS library that generates and manages contextual cards displayed at the bottom of the screen

BulletinBoard is an iOS library that generates and manages contextual cards displayed at the bottom of the screen. It is especially well

💾 A collection of classic-style UI components for iOS
💾 A collection of classic-style UI components for iOS

A collection of classic-style UI components for UIKit, influenced by Windows 95 Introduction This is a little exploration into applying '90s-era desig

A simple, customizable view for efficiently collecting country information in iOS apps.
A simple, customizable view for efficiently collecting country information in iOS apps.

CountryPickerView CountryPickerView is a simple, customizable view for selecting countries in iOS apps. You can clone/download the repository and run

A library to recreate the iOS Apple Music now playing transition
A library to recreate the iOS Apple Music now playing transition

DeckTransition DeckTransition is an attempt to recreate the card-like transition found in the iOS 10 Apple Music and iMessage apps. Hereʼs a GIF showi

A message bar for iOS written in Swift.
A message bar for iOS written in Swift.

Dodo, a message bar for iOS / Swift This is a UI widget for showing text messages in iOS apps. It is useful for showing short messages to the user, so

Protocol oriented, type safe, scalable design system foundation swift framework for iOS.
Protocol oriented, type safe, scalable design system foundation swift framework for iOS.

Doric: Design System Foundation Design System foundation written in Swift. Protocol oriented, type safe, scalable framework for iOS. Features Requirem

A Material Design drop down for iOS
A Material Design drop down for iOS

A Material Design drop down for iOS written in Swift. Demo Do pod try DropDown in your console and run the project to try a demo. To install CocoaPods

An easy to use FAQ view for iOS written in Swift
An easy to use FAQ view for iOS written in Swift

FAQView An easy to use FAQ view for iOS written in Swift. This view is a subclass of UIView. Setup with CocoaPods If you are using CocoaPods add this

A custom reusable circular / progress slider control for iOS application.
A custom reusable circular / progress slider control for iOS application.

HGCircularSlider Example To run the example project, clone the repo, and run pod install from the Example directory first. You also may like HGPlaceho

Releases(1.0.1)
Owner
Ricardo Canales
Ricardo Canales
You can dismiss modal viewcontroller like Facebook Messenger by pulling scrollview or navigationbar in Swift.

PullToDismiss PullToDismiss provides dismiss modal viewcontroller function like Facebook Messenger by pulling scrollview or navigationbar with smooth

Suguru Kishimoto 479 Dec 5, 2022
⚡️ A library of widgets and helpers to build instant-search applications on iOS.

By Algolia. InstantSearch family: InstantSearch iOS | InstantSearch Android | React InstantSearch | InstantSearch.js | Angular InstantSearch | Vue Ins

Algolia 567 Dec 20, 2022
Material, a UI/UX framework for creating beautiful iOS applications

Material Welcome to Material, a UI/UX framework for creating beautiful applications. Material's animation system has been completely reworked to take

Cosmicmind 12k Jan 2, 2023
Full configurable spreadsheet view user interfaces for iOS applications. With this framework, you can easily create complex layouts like schedule, gantt chart or timetable as if you are using Excel.

kishikawakatsumi/SpreadsheetView has moved! It is being actively maintained at bannzai/SpreadsheetView. This fork was created when the project was mov

Kishikawa Katsumi 34 Sep 26, 2022
Easily use UIKit views in your SwiftUI applications. Create Xcode Previews for UIView elements

SwiftUIKitView Easily use UIKit views in SwiftUI. Convert UIView to SwiftUI View Create Xcode Previews from UIView elements SwiftUI functional updatin

Antoine van der Lee 682 Dec 29, 2022
UI framework that allows developers to integrate an amazing selection interface into their applications

UI framework that allows developers to integrate an amazing selection interface into their applications! Each bubble has a set of parameters, which could be configured individually.

AJIJIi 5 Jul 12, 2022
UIStackView replica for iOS 7.x and iOS 8.x

TZStackView A wonderful layout component called the UIStackView was introduced with iOS 9. With this component it is really easy to layout components

Tom van Zummeren 1.2k Oct 10, 2022
Super awesome Swift minion for Core Data (iOS, macOS, tvOS)

⚠️ Since this repository is going to be archived soon, I suggest migrating to NSPersistentContainer instead (available since iOS 10). For other conven

Marko Tadić 306 Sep 23, 2022
A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView and iPhone X safe area support for content reloading. Built for iOS 10 and later.

Arale A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView support for reloading your content. Built f

Putra Z. 43 Feb 4, 2022