All Projects → SteveBarnegren → SBCardPopup

SteveBarnegren / SBCardPopup

Licence: MIT License
Card Popup UI for iOS

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to SBCardPopup

LSDialogViewController
Custom Dialog for iOS written in Swift
Stars: ✭ 74 (+12.12%)
Mutual labels:  modal, popup
vue-modal
A customizable, stackable, and lightweight modal component for Vue.
Stars: ✭ 96 (+45.45%)
Mutual labels:  modal, popup
vue-modal
Reusable Modal component, supports own custom HTML, text and classes.
Stars: ✭ 29 (-56.06%)
Mutual labels:  modal, popup
Transition
Easy interactive interruptible custom ViewController transitions
Stars: ✭ 2,566 (+3787.88%)
Mutual labels:  view, viewcontroller
MVVM-Design-Pattern-Demo
An Xcode 9 project written in Swift 4 code designed using the MVVM design pattern, truly extolling the virtues of MVVM over MVC.
Stars: ✭ 31 (-53.03%)
Mutual labels:  view, viewcontroller
react-layer-stack
Layering system for React. Useful for popover/modals/tooltip/dnd application
Stars: ✭ 158 (+139.39%)
Mutual labels:  modal, popup
react-spring-bottom-sheet
Accessible ♿️, Delightful ✨, & Fast 🚀
Stars: ✭ 604 (+815.15%)
Mutual labels:  modal, popup
Nativepopup
Clone of Apple iOS App's feedback popup, and easily customizable.
Stars: ✭ 247 (+274.24%)
Mutual labels:  modal, popup
react-redux-modal-flex
[DEPRECATED] Make easy a modal/popup with Redux
Stars: ✭ 14 (-78.79%)
Mutual labels:  modal, popup
eins-modal
Simple to use modal / alert / dialog / popup. Created with pure JS. No javascript knowledge required! Works on every browser and device! IE9
Stars: ✭ 30 (-54.55%)
Mutual labels:  modal, popup
React Native Popover View
A well-tested, adaptable, lightweight <Popover> component for react-native
Stars: ✭ 191 (+189.39%)
Mutual labels:  view, modal
plain-modal
The simple library for customizable modal window.
Stars: ✭ 21 (-68.18%)
Mutual labels:  modal, popup
Rdgliderviewcontroller Swift
Control for a floating view gliding over a ViewController Edit
Stars: ✭ 102 (+54.55%)
Mutual labels:  view, viewcontroller
jpopup
Simple lightweight (<2kB) javascript popup modal plugin
Stars: ✭ 27 (-59.09%)
Mutual labels:  modal, popup
Tocropviewcontroller
A view controller for iOS that allows users to crop portions of UIImage objects
Stars: ✭ 4,210 (+6278.79%)
Mutual labels:  view, viewcontroller
MultiModal
Use multiple .sheet, .alert, etc. modifiers in the same SwiftUI View
Stars: ✭ 49 (-25.76%)
Mutual labels:  view, modal
React Native Simple Dialogs
⚛ Cross-platform React Native dialogs based on the Modal component
Stars: ✭ 218 (+230.3%)
Mutual labels:  modal, popup
Django Bootstrap Modal Forms
A Django plugin for creating AJAX driven forms in Bootstrap modal.
Stars: ✭ 244 (+269.7%)
Mutual labels:  modal, popup
RDGliderViewController
Control for a floating view gliding over a ViewController
Stars: ✭ 31 (-53.03%)
Mutual labels:  view, viewcontroller
react-native-popup
React Native Animated Popup Modal
Stars: ✭ 19 (-71.21%)
Mutual labels:  modal, popup

SBCardPopup

Version License Platform

Easily show a UIViewController or UIView in a popup card UI.

cardgif

Example

Run Example/SBCardPopupExample.xcodeproj

Usage

Showing a popup

Create an SBCardPopupViewController passing in your view controller. (There is a method to pass in a UIView subclass if you prefer).

Call show() passing in the current view controller.

let cardPopup = SBCardPopupViewController(contentViewController: myViewController)
cardPopup.show(onViewController: self)

SBCardPopupContent protocol

Your view controller can optionally conform to the SBCardPopupContent protocol. This allows the view controller to enable/disable the tap and swipe to dismiss gestures.

public protocol SBCardPopupContent: class {
    weak var popupViewController: SBCardPopupViewController? {get set}
    var allowsTapToDismissPopupCard: Bool {get}
    var allowsSwipeToDismissPopupCard: Bool {get}
}

The protocol will also ensure that your view controller has a reference to it's SBCardPopupViewController container. This is useful if it needs to dismiss itself, for instance, on a button press.

@IBAction func closeButtonPressed(sender: UIButton){
	popupViewController?.close()
}

Customisation

Public properties can be modified for the SBCardPopupViewController corner radius, and also flags to disable dismiss gestures. These flags take precendece over the SBCardPopupContent protocol.

If you wish to disable gestures for all popups, it can be more convinient to do this on the SBCardPopupViewController before it is presented, and create a single popup presentation point in your application so that these setting are always used.

extension UIViewController {

	func presentViewControllerAsPopup(_ viewController: UIViewController) {
		
		let cardPopup = SBCardPopupViewController(contentViewController: viewController)
		cardPopup.cornerRadius = 5
		cardPopup.allowsTapToDismissPopupCard = true
		cardPopup.allowsSwipeToDismissPopupCard = false
		cardPopup.show(onViewController: self)
	}
}

Creating Popup UI

SBCardPopupViewController uses AutoLayout, which makes it easy to size the card correctly around the content. It does, however, mean that you need to provide constraints that fully describe the height of the card.

In the following example, the top label is pinned to the top of the view controller, and the bottom label is pinned to the bottom. As there is no constraint connecting the two labels, the distance between them is not known, this will case issues when trying to size the popup card.

IMG

By adding a constraint between the two labels, the full height of the card has been described. In order to resolve errors in Interface Builder, you will need to size your view contoller to match the output of the constraints, or make one of the constraints low priority.

IMG

Installation

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

pod "SBCardPopup"

Author

Steve Barnegren, [email protected]

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].