You can dismiss modal viewcontroller like Facebook Messenger by pulling scrollview or navigationbar in Swift.

Overview

PullToDismiss

PullToDismiss provides dismiss modal viewcontroller function like Facebook Messenger by pulling scrollview or navigationbar with smooth and rich background effect.

GitHub release Language Carthage Compatible CocoaPods CocoaPodsDL Awesome Reviewed by Hound


sample blur sample
gif gif

Feature

  • Support all scroll views. (UIScrollView, UITableView, UICollectionView, UIWebView, WKWebView)
  • Customizable. (dismiss background color, alpha, height percentage of dismiss)
  • Available in UIViewController, UINavigationController.
  • Automatically add pan gesture to navigation bar.
  • Blur effect support.
  • Objective-C support. (from v2.1~)

Migration guide

If you update from 1.x to 2.0, see migration guide if needed.

Usage

Getting Started

(1) Setup PullToDismiss

import PullToDismiss

class SampleViewController: UIViewController {
    @IBOutlet private weak var tableView: UITableView!
    private var pullToDismiss: PullToDismiss?
    override func viewDidLoad() {
        super.viewDidLoad()
        pullToDismiss = PullToDismiss(scrollView: tableView)
    }
}

(2) Create view controller and set modalPresentationStyle. Then present view controller

let vc = SampleViewController()
let nav = UINavigationController(rootViewController: vc)
nav.modalPresentationStyle = .overCurrentContext

self.present(nav, animated: true, completion: nil)

👍 👍 👍

Use (UIScrollView|UITableView|UICollectionView)Delegate

You can use all scroll view's delegate by set pullToDismiss.delegate.

import PullToDismiss

class SampleViewController: UIViewController {
    @IBOutlet private weak var tableView: UITableView!
    private var pullToDismiss: PullToDismiss?
    override func viewDidLoad() {
        super.viewDidLoad()
        pullToDismiss = PullToDismiss(scrollView: tableView)
        pullToDismiss?.delegate = self
    }
}

extension SampleViewController: UITableViewDelegate {
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        // ...
    }

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        // ...
    }
}

Customize

You can customize backgroundEffect, dismissableHeightPercentage:

Shadow background effet

  • background (default: ShadowEffect.default, [color: black, alpha: 0.8])

img1

pullToDismiss?.background = ShadowEffect(color: .red, alpha: 0.5) // color: red, alpha: 0.5

Blur background effect

New feature for v1.0.

gif

// preset blur (.extraLight, .light, .dark)
pullToDismiss?.background = BlurEffect.extraLight

// set custom Blur
pullToDismiss?.background = BlurEffect(color: .red, alpha: 0.5, blurRadius: 40.0, saturationDeltaFactor: 1.8)

dismissableHeightPercentage

img2

// to pull half size of view controller, dismiss view controller.
pullToDismiss?.dismissableHeightPercentage = 0.5

Requirements

  • iOS 8.0+ (blur effect: iOS 9.0+)
  • Xcode 8.1+
  • Swift 3.0+

Installation

Carthage

  • Add the following to your Cartfile:
# Swift 5.0 or later
github "sgr-ksmt/PullToDismiss" ~> 2.2
# Swift 3
github "sgr-ksmt/PullToDismiss", 2.1
  • Run carthage update
  • Add the framework as described.
    Details: Carthage Readme

CocoaPods

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

# Swift 5.0 or later
pod 'PullToDismiss', '~> 2.2'
# Swift 3
pod 'PullToDismiss', '2.1'

and run pod install

Manually Install

Download all *.swift files and put your project.

Change log

Change log is here.

Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request. 💪

License

PullToDismiss is under MIT license. See the LICENSE file for more info.

Comments
  • Updates README with updated backgroundEffect

    Updates README with updated backgroundEffect

    Previous README was a bit outdated and the instructions for backgroundEffect said pullToDismiss?.background instead of pullToDismiss?.backgroundEffect, which confused me so I took a look at the source code and corrected the mistake in case anybody else uses this and is confused


    Updates the README to what current source code for PullToDismiss.swift looks like

    opened by mding5692 2
  • need to update syntax in Swift 5

    need to update syntax in Swift 5

    • UIBlurEffectStyle has been renamed to UIBlurEffect.Style -> this is the error in CustomBlurView: UIVisualEffectView
    • .sendSubview(toBack:) has been renamed to sendSubviewToBack(_:) -> this is the error in class PullToDismiss: NSObject
    opened by j-elmer123 1
  • Adding actions for beginning and ending dismiss.

    Adding actions for beginning and ending dismiss.

    This is in order to prepare the underlying view for any updates that occurred on the view above.

    Because the dismiss percentage is abstracted and private, this or something similar is necessary in some applications/instances.

    opened by benguild 1
  • Fixing issue with `UIPageViewController` outermost parent.

    Fixing issue with `UIPageViewController` outermost parent.

    I noticed that this works well with UIPageViewController (embedded within an additional parent, for example) only if resolving the topmost parent UIViewController. I'm assuming that this is probably most ideal in all situations, but that the previous convenience of calling "dismiss" on the closest UIViewController also worked in most instances.

    This fixes the issue that I ran into. — An alternative would be to have a weak property that can be overridden to track which UIViewController to actually dismiss in case it's a less typical choice, but I'm guessing that's unnecessary.

    opened by benguild 1
  • Updates backgroundEffect code on README

    Updates backgroundEffect code on README

    @sgr-ksmt Previously README had pullToDismiss?.background instead of pullToDismiss?.backgroundEffect which was wrong and confused me and I figured it out by looking through the source code for PullToDismiss.swift. Thanks again for this repo! 👍

    Issue

    • Issue Number: #39

    Updates the README.md so that it has the correct instructions for changing PullToDismiss's backgroundEffect.

    opened by mding5692 1
  • README is outdated

    README is outdated

    Thanks again for the repo and open sourcing it, using it currently right now in my app and I noticed an issue with the README. Probably going to post a PR soon as its an easy change.

    The README says pullToDismiss?.background instead of pullToDismiss?.backgroundEffect for changing the background which is wrong and I figured it out through having to look through the source code PullToDismiss.swift.

    opened by mding5692 1
  • Added support for Objective-C

    Added support for Objective-C

    Added Objective-C compatibility. Tested in a live production app and it works without any issues. Structs are now classes inheriting from NSObject, and extensions are public. I don't believe this will cause any issues with existing swift integrations, but I'd be happy to look into this further if that is in fact the case.

    opened by MrMatthewDavis 1
  • Release/2.0

    Release/2.0

    • [x] Realistic animation #24, #26
    • [x] Redesign of ProxyDelegate #25, #27
    • [x] Update README.md
    • [x] Prepare Migration Guide
    • [x] Create unavailable.swift for migration from 1.x.
    • [x] Update CHANGELOG.md
    opened by sgr-ksmt 1
  • Redesign of proxyDelegate

    Redesign of proxyDelegate

    As of now, we need some specific delegate methods to make PullToDismiss work. If we want to use delegate methods other than the specific ones, we have no choice but to implement them as a method in PullToDismiss's subclass.

    You know, that is not cool. 😢

    class CustomPullToDismiss: PullToDismiss {
        func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
            return tableViewDelegate?.tableView?(tableView, heightForRowAt: indexPath) ?? 44.0
        }
    }
    
    class SampleViewController: UIViewController {
        @IBOutlet private weak var tableView: UITableView!
        private var pullToDismiss: PullToDismiss?
        override func viewDidLoad() {
            super.viewDidLoad()
            pullToDismiss = CustomPullToDismiss(scrollView: tableView)
            pullToDismiss.delegateProxy = self
        }
    }
    
    extension SampleViewController: UITableViewDelegate {
        // called by CustomPullToDismiss
        func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
            return indexPath.section == 0 ? 44.0 : 60.0
        }
    
        // ...
    }
    

    That is why I decided to restructure the design of delegate proxy so that implementing more delegate methods into the subclass will be no longer needed.

    opened by sgr-ksmt 0
  • Is there a way to present so it doesn't take up the entire superview?

    Is there a way to present so it doesn't take up the entire superview?

    Is there a way to specify the hieght of the PullToDismiss view, without having it take up the entire screen? I tried this:

    let vc = LikesTableController()
            vc.preferredContentSize = CGSize(width: view.frame.width, height: 200)
            present(vc, animated: true)
    

    but it doesn't work....

    opened by jderbs 0
  • TableView Delegate not work

    TableView Delegate not work

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    }

    this function of UITableView does not work when using PullToDismiss. How to fix it ?????

    opened by ghost 1
  • [bug] Status-bar-hiding avoiding code doesn't work consistently

    [bug] Status-bar-hiding avoiding code doesn't work consistently

    This doesn't always work: https://github.com/sgr-ksmt/PullToDismiss/blob/master/Sources/PullToDismiss.swift#L173-L175

    Example: if you drag a UINavigationController with a UIViewController that has a UIScrollView in it, upward (into negative space) before dragging it downward, it may skip over the detection range of 0 -> 0.5 that's prescribed here, and the status bar is hidden on that view.

    Depending on what you're doing, this is an oversight.

    opened by benguild 1
  • New feature request: Dismissing is too sensitive to drag velocity

    New feature request: Dismissing is too sensitive to drag velocity

    Hi, I find the dismiss action too sensitive to drag velocity, so that the modal is dismissed too easily. Is it possible to expose some property (similar to dismissableHeightPercentage property) so that we're able to increase resistance to drag velocity?

    opened by ElectroBuddha 1
Releases(2.1)
Owner
Suguru Kishimoto
iOS/Web Developer and Technical Advisor for Firebase. 💖:Swift/TypeScript/Firebase/React
Suguru Kishimoto
A SwiftUI ScrollView Designed to imitate the App Store and Apple Music ScrollViews (with or without a Parallax Header)

FancyScrollView I spent a lot of time looking for a way to recreate the UI of the ScrollViews in Stock Apple Apps (i.e. App Store and Apple Music) ins

Mathias Quintero 696 Dec 30, 2022
MacOS scrollview nsview scrollbar bug demo

macOS SwiftUI ScrollView Scrollbar Bug Demo If you create a ScrollView that contains an NSView that intersects the scroll view's scrollbars, the scrol

Matt Curtis 0 Nov 14, 2021
SwiftUI ScrollView with custom pull to refresh & scroll to load-more implementations

PaginatedScrollView SwiftUI ScrollView with custom "pull to refresh" & "scroll to load-more" implementations. example usage PaginatedScrollView {

Aung Ko Min 7 Sep 20, 2022
Add snapping behaviour to a SwiftUI ScrollView

SwiftUI Snapping ScrollView Add snapping behaviour to a SwiftUI ScrollView. SnappingScrollView A scrollable view that supports snapping. Usage Snappin

Ciaran O'Brien 21 Dec 27, 2022
This is a control that helps you dramatically ease your infinite scroll processing.

InfiniteScrollControl Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installat

Minseok Kang 0 Nov 15, 2021
A scroll view with a sticky header which shrinks as you scroll. Written with SwiftUI.

Scaling Header Scroll View A scroll view with a sticky header which shrinks as you scroll. Written with SwiftUI. We are a development agency building

Exyte 395 Dec 31, 2022
↕️ VegaScroll is a lightweight animation flowlayout for UICollectionView completely written in Swift 4, compatible with iOS 11 and Xcode 9.

Made by Applikey Solutions Find this project on Dribbble Also check another flowlayout for UICollectionView: https://github.com/ApplikeySolutions/Grav

Applikey Solutions 2.8k Jan 7, 2023
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
You can dismiss modal by using gesture

RPModalGestureTransition You can dismiss modal by using gesture. Usage 1.Define animation You define animator class inherits UIViewControllerAnimatedT

Naoya Sugimoto 90 Apr 21, 2020
A custom modal transition that presents and dismiss a controller with an expanding bubble effect.

A custom modal transition that presents and dismiss a controller inside an expanding and shrinking bubble. Screenshot Usage Install through CocoaPods:

Andrea Mazzini 3.3k Dec 28, 2022
The horizontal swiping navigation like on Facebook Messenger.

UIMenuScroll UIMenuScroll creating menu how on Facebook Messenger on take photo Installation CocoaPods is a dependency manager for Cocoa projects. You

Aleksey Pleshkov 18 Aug 9, 2022
Photo Browser / Viewer inspired by Facebook's and Tweetbot's with ARC support, swipe-to-dismiss, image progress and more

IDMPhotoBrowser IDMPhotoBrowser is a new implementation based on MWPhotoBrowser. We've added both user experience and technical features inspired by F

Thiago Peres 2.7k Dec 21, 2022
Present a sheet ViewController easily and control ViewController height with pangesture

PanControllerHeight is designed to present a sheet ViewController easily and control ViewController height with pangesture.

null 2 May 3, 2022
custom navigationBar in swiftui

SwiftUI-WRNavigationBar custom navigationBar in swiftui Requirements iOS 14.0 Installation pod 'SwiftUI-WRNavigationBar', '~>1.1.1' Overview debug cus

wangrui460 29 Nov 7, 2022
DTPhotoViewerController - A fully customizable photo viewer ViewController to display single photo or collection of photos, inspired by Facebook photo viewer.

DTPhotoViewerController Example Demo video: https://youtu.be/aTLx4M4zsKk DTPhotoViewerController is very simple to use, if you want to display only on

Tung Vo 277 Dec 17, 2022
Mybook swiftui - A Facebook UI Clone with some capabilities like like/unlike, comment, scroll, show stories etc

mybook_swiftui ?? Trying to create a Facebook UI Clone with some capabilities li

mogolAyberk 1 Apr 16, 2022
SwiftUI ScrollView can pull to fresh

FreshScrollView SwiftUI ScrollView can pull to fresh One day, when I were writing a scrollview with a SwiftUI, I suddenly wanted to add a drop-down re

Weiha Wang 1 Dec 12, 2021
SwiftUI ScrollView can pull to fresh

FreshScrollView SwiftUI ScrollView can pull to fresh One day, when I were writing a scrollview with a SwiftUI, I suddenly wanted to add a drop-down re

Weiha Wang 0 Dec 8, 2021
Create ImageView for User or Group like Messenger app

MessengerBubbles Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installation C

Laurent Grondin 29 Mar 8, 2022
Awesome looking Dial like card selection ViewController

KVCardSelectionVC Awesome looking Dial like card selection ViewController An updated Swift 3 working version of : https://github.com/atljeremy/JFCardS

Kunal Verma 23 Feb 1, 2021