Popover is a balloon library like Facebook app. It is written in pure swift.

Related tags

Popup Popover
Overview

Popover

CI Status Version License Platform

Description and appetize.io`s DEMO

Usage

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

Simple

let startPoint = CGPoint(x: self.view.frame.width - 60, y: 55)
let aView = UIView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 180))
let popover = Popover()
popover.show(aView, point: startPoint)

Custom

@IBOutlet weak var leftBottomButton: UIButton!

let width = self.view.frame.width / 4
let aView = UIView(frame: CGRect(x: 0, y: 0, width: width, height: width))
let options = [
  .type(.up),
  .cornerRadius(width / 2),
  .animationIn(0.3),
  .blackOverlayColor(UIColor.red),
  .arrowSize(CGSize.zero)
  ] as [PopoverOption]
let popover = Popover(options: options, showHandler: nil, dismissHandler: nil)
popover.show(aView, fromView: self.leftBottomButton)

Requirements

  • iOS 9.0+
  • Swift 5

Installation

CocoaPods (iOS 8+)

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

use_frameworks!
pod "Popover"

Carthage (iOS 8+)

You can use Carthage to install Popover by adding it to your Cartfile:

github "corin8823/Popover"

Manual Installation

The class file required for Popover is located in the Classes folder in the root of this repository as listed below:

Popover.swift

Customization

Enum

  • case arrowSize(CGSize)
  • case animationIn(NSTimeInterval)
  • case animationOut(NSTimeInterval)
  • case cornerRadius(CGFloat)
  • case sideEdge(CGFloat)
  • case blackOverlayColor(UIColor)
  • case overlayBlur(UIBlurEffectStyle)
  • case type(Popover.PopoverType)
  • case color(UIColor)
  • case dismissOnBlackOverlayTap(Bool)
  • case showBlackOverlay(Bool)

Property

  • arrowSize: CGSize = CGSize(width: 16.0, height: 10.0)
  • animationIn: NSTimeInterval = 0.6
  • animationOut: NSTimeInterval = 0.3
  • cornerRadius: CGFloat = 6.0
  • sideEdge: CGFloat = 20.0
  • popoverType: PopoverType = .down
  • blackOverlayColor: UIColor = UIColor(white: 0.0, alpha: 0.2)
  • overlayBlur: UIBlurEffect?
  • popoverColor: UIColor = UIColor.white

Acknowledgments

Inspired by DXPopover in xiekw2010

License

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

Comments
  • Not able to dismiss the popover

    Not able to dismiss the popover

    Hello, I am displaying a popover on a gesture recogniser. The popover shows a custom collectionview. But i am not able to dismiss the popover by using popover.dismiss.

    Here is my code:

    ` class KeyboardViewController: UIInputViewController , ISEmojiViewDelegate, UICollectionViewDelegate, UICollectionViewDataSource {

    var extras : [String] = []
    
    fileprivate var popover1: Popover!
    
    //setting up everything
    
    func ShowPop(_ sender: UILongPressGestureRecognizer) {
    	self.popover1 = Popover(options: [.type(.up), .showBlackOverlay(false)])
    	self.popover1.willShowHandler = {
    		print("willShowHandler")
    	}
    	self.popover1.didShowHandler = {
    		print("didshowHandler")
    	}
    	self.popover1.willDismissHandler = {
    		print("willDismissHandler")
    	}
    	self.popover1.didDismissHandler = {
    		print("didDismissHandler")
    	}
    	if sender.state == .began {
    		//get the button
    		if let button = sender.view as? UIButton {
    			switch button.tag {
    			case 50 : extras = ["è","é","ê","ë","ē"]
    						break
    			case 55 : extras = ["ì","í","î","ï"]
    						break
    			case 60 : extras = ["ò","ó","ô","õ","ö"]
    						break
    			case 65 : extras = ["à","á","â","ã","ä"]
    						break
    			case 70 : extras = ["È","É","Ê","Ë","Ē"]
    						break
    			case 75 : extras = ["Ì","Í","Î","Ï"]
    						break
    			case 80 : extras = ["Ò","Ó","Ô","Õ","Ö"]
    						break
    			case 85 : extras = ["À","Á","Â","Ã","Ä"]
    						break
    				default:
    						print("none")
    			} //end switch
    			let fl = UICollectionViewFlowLayout()
    			fl.minimumLineSpacing = 0
    			fl.minimumInteritemSpacing = 0
    			let width = self.view.frame.width / 4
    			let aView = UICollectionView(frame: CGRect(x: 0, y: 0, width: width, height: (emojibottom.frame.height)), collectionViewLayout: fl)
    			aView.delegate = self
    			aView.dataSource = self
    			aView.isScrollEnabled = false
    			aView.allowsMultipleSelection = false
    			aView.register(UINib.init(nibName: "ViewCell", bundle: nil), forCellWithReuseIdentifier: "myCell")
    			self.popover1.show(aView, fromView: button, inView: self.view)
    		} //end if button
    	} //end if state
    }
    
    //collection view
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
    	let cell = collectionView.cellForItem(at: indexPath) as! CollectionViewCell
    	(textDocumentProxy as UIKeyInput).insertText(cell.tLabel.text!)
    	popover1.dismiss()
    }
    
    
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    	if extras.count > 0 {
    		return extras.count}
    	else {return 0 }
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    	let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "myCell", for: indexPath) as! CollectionViewCell
    	cell.tLabel.text = extras[indexPath.row]
    	return cell
    }
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout,sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {
    	let width = collectionView.frame.width/(CGFloat(extras.count))
    	let height = collectionView.frame.height
    	return CGSize(width: width, height: height)
    }
         }
    

    `

    but whenever I select something from the popover, it does not dismiss.

    opened by BhaktiKarva 16
  • Build Error

    Build Error

    Helo, I just installed version 1.0.4 because I am using Swift 3.0 I tried to build the project but it gives me error in the Popover.swift file at - self.showAsDialog(contentView, inView: UIApplication.shared.keyWindow!) error - 'shared' is unavailable. Use view controller based solutions where appropriate instead.

    Please help.

    opened by BhaktiKarva 11
  • Ignoring  bogus layer size

    Ignoring bogus layer size

    Great UI framework, thanks! I created a new class that launches a popover from a custom toolbar ( see RichEditorView framework), the popover has a UIToolbar as content view. Some bar button items in the RichEditorView Toolbar launch the popover, so I reuse the popover but change the items in the toolbar content view (see note taking apps like Evernote, same logic). When I tap the same item on the RichEditorToolbar a second time, the popover doesn't appear. it appears only the first time or if I tap another item...

    Console prints this warning:** [<CALayer: 0x7fda7b3160c0> display]: Ignoring bogus layer size (1390000.000000, 540000.000000), contentsScale 2.000000, backing store size (2780000.000000, 1080000.000000)**

    Does anyone experience the same problem? I can't exclude that it has to do with something else going on in my app / view controller... Any idea what the cause might be?

    As shown in the gif below, the popover actually shows the black layover view in the background but the popover itself does not appear...

    popover launching only on 2nd tap

    thanks for any hints in the right direction

    opened by DominikButz 5
  • How to set options in Objective-C

    How to set options in Objective-C

    Im trying to use your library in an Objective-C project but i don't seem to find out how to set options to a popover object .. Could someone help me ? Thank you

    opened by rico237 5
  • How to customize arrow

    How to customize arrow

    Hi, I want to make a custom view with border but I want to make the border with the arrow, now I have this:

    image

    But I want to make something like this.

    image

    Can you help me? Thanks :)

    opened by marioilianov94 4
  • Issue about swift3.0 from cocoapods

    Issue about swift3.0 from cocoapods

    Hello guy Firstly, This is an awesome library popover swift 💯 I see in requirement, it supports xCode 8+ and swift 3.0 but when I install from pods it has only version 0.9.1. So if i mistake anywhere, i need advice from you. thank

    opened by catmans1 4
  • This is supposed to fix broken corner in case it is very close to an edge (for .down direction only)

    This is supposed to fix broken corner in case it is very close to an edge (for .down direction only)

    The corner used to be corrected in case it its point is exactly at an edge, but in case the corner is not at the edge there was some visual cut-out. Not sure, but probably it is also mentioned in the issue #33

    How it used to be: Screenshot 2019-11-04 17 09 42

    After fix: Screenshot 2019-11-04 17 10 41

    opened by vitalii-tym 3
  • Popover is not visible / doesn't appear

    Popover is not visible / doesn't appear

    using this function:

      open func show(_ contentView: UIView, fromView: UIView) {
        guard let rootView = UIApplication.shared.windows.last ?? UIApplication.shared.keyWindow else {
            return
        }
        self.show(contentView, fromView: fromView, inView: rootView)
      }
    
    

    I have a problem. Just show popover is okay, but when i do something like open another screen and then come back, I have popover invisible. Researched the problem, i have:

    (lldb) po rootView
    <UIRemoteKeyboardWindow: 0x7fbd7775bee0; frame = (0 0; 414 736); opaque = NO; autoresize = W+H; layer = <UIWindowLayer: 0x60000003e300>>
    

    when return from another controller.

    opened by Maxatma 3
  • iOS11 not show

    iOS11 not show

    open func show(_ contentView: UIView, point: CGPoint) { // guard let rootView = UIApplication.shared.windows.last ?? UIApplication.shared.keyWindow else { // return // } // This works good guard let rootView = UIApplication.shared.keyWindow ?? UIApplication.shared.windows.last else { return } self.show(contentView, point: point, inView: rootView) }

    In iOS11: UIApplication.shared.keyWindow ?? UIApplication.shared.windows.last is _UIInteractiveHighlightEffectWindow?

    opened by codwam 3
  • Hide overlay option

    Hide overlay option

    Allows user to hide overlay, which allows taps on the UI to be processed normally. Useful for apps that want to hide/show popovers based on user actions.

    opened by phatmann 3
  • [Resolved] Inifinite layoutSubviews loop

    [Resolved] Inifinite layoutSubviews loop

    opened by jonathan-vinova 3
  • Popup OriginPoint coming from TabBar for reasons?

    Popup OriginPoint coming from TabBar for reasons?

    I have a situation to where the origin of the pop over is coming from my tab bar instead of the button itself. I assume this must be because I have the button within a PageViewController. Possibly I should be using something other than 'sender.frame', but I don't know what.

        @IBAction func button1Action(_ sender: UIButton) {
            
            
            //Origin Point
            let originPoint = CGPoint(x: sender.frame.midX, y: sender.frame.maxY + 158) //(Y = down)
            
            let popoverView = UIView(frame: CGRect(x: 32, y: sender.bounds.maxY + 20, width: self.view.bounds.width - 64, height: 200))
            
            let textLabel = UILabel(frame: CGRect(x: +15, y: 0, width: popoverView.bounds.width - 15, height: popoverView.bounds.height))
            
            textLabel.lineBreakMode = .byWordWrapping
            textLabel.numberOfLines = 0
            textLabel.textColor = .white
            textLabel.text = "Use neutral framing of the events rather than perceptually colored language. eg:\n\n____ event occured.\n____ person said: '____'.\n____ object was altered in ____ way."
            textLabel.textAlignment = .left
    
            
            popoverView.addSubview(textLabel)
            
            
            let options: [PopoverOption] = [
                .cornerRadius(25),
                .color(.systemTeal)
            ]
            
            let popover = Popover(options: options)
            popover.show(popoverView, point: originPoint)
    
        }
    
    opened by swimnbird 1
  • transform change it's subview's frame

    transform change it's subview's frame

    Execuse me,

    I have set contentView.frame = CGRect(0, 10, 100, 100). But after a Popover transform in func show(), it's contentView has changed frame. Then I find:

    override open func layoutSubviews() {
       super.layoutSubviews()
       self.contentView.frame = self.bounds
     }
    

    scale tranform will execute this code, and contentView.frame will be changed.

    Thank you!

    opened by jiangliansong19 0
  • When tableView is larger than popoverView

    When tableView is larger than popoverView

    https://user-images.githubusercontent.com/29369132/112786462-7e0e1d80-9080-11eb-8b9e-ba53bf826266.mov

    cell.backgroundColor = .clear https://user-images.githubusercontent.com/29369132/112787129-10fb8780-9082-11eb-802f-8d14a4d16d91.mov

    how to fix the bottom inset of uitableview to fit popover?

    Thanks.

    opened by sseno 1
Releases(1.2.2)
Owner
Yusuke Takahashi
Yusuke Takahashi
A framework for presenting bars and view controllers as popup, much like the look and feel of Apple Music App.

PBPopupController PBPopupController is a framework for presenting bars and view controllers as popup, much like the look and feel of Apple Music App.

Patrick 58 Dec 3, 2022
Subscription View Controller like the Tinder uses

SubscriptionPrompt SubscriptionPrompt is a UIViewController with a carousel at the top and a number of rows at the bottom. Written in Swift, works for

Binur Konarbai 235 Nov 17, 2022
LNPopupController is a framework for presenting view controllers as popups of other view controllers, much like the Apple Music and Podcasts apps.

LNPopupController LNPopupController is a framework for presenting view controllers as popups of other view controllers, much like the Apple Music and

Leo Natan 2.9k Jan 2, 2023
Toasts and popups library written with SwiftUI

Popup View Toasts and popups library written with SwiftUI We are a development agency building phenomenal apps. Usage Put all your body code into a ZS

Exyte 1.9k Jan 6, 2023
A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.

Introduction Popup Dialog is a simple, customizable popup dialog written in Swift. Features Easy to use API with hardly any boilerplate code Convenien

Orderella Ltd. 3.8k Dec 20, 2022
SSToastMessage is written purely in SwiftUI. It will add toast, alert, and floating message view over the top of any view. It is intended to be simple, lightweight, and easy to use. It will be a popup with a single line of code.

SSToastMessage SSToastMessage is written in SwiftUI. It will add toast, alert, and floating message view over the top of any view. It is intended to b

Simform Solutions 223 Dec 2, 2022
A lightweight library for popup view

SHPopup SHPop is lightweight library used for popup view Sample One Sample Two Sample Three Features SHPopup supports a popup inside another popup wit

Shezad Ahamed 37 Oct 2, 2022
SwiftEntryKit is a presentation library for iOS. It can be used to easily display overlays within your iOS apps.

SwiftEntryKit ?? Donations can be made here. Table of Contents Overview Features Example Project Example Project Installation Presets Playground Requi

Daniel Huri 6.1k Jan 6, 2023
The library allows to create simple popup menus

react-native-popup-menu This library allows to create simple popup menus Installation "react-native-popup-menu": "sergeymild/react-native-popup-menu"

SergeyMild 0 Aug 20, 2022
Simple Swift class for iOS that shows nice popup windows with animation.

NMPopUpView Simple class for iOS that shows nice popup windows, written in Swift. The project is build with Swift 4.0, so you need Xcode 9.0 or higher

Nikos Maounis 194 Jun 5, 2022
Swift wrapper for custom ViewController presentations on iOS

Presentr is a simple customizable wrapper for the Custom View Controller Presentation API introduced in iOS 8. About iOS let's you modally present any

Icalia Labs 2.9k Jan 3, 2023
PopupWindow is a simple Popup using another UIWindow in Swift

PopupWindow PopupWindow is a simple Popup using another UIWindow Feature PopupWindow can be displayed at the top or bottom of the screen. Popup can se

shinji hayashi 415 Dec 5, 2022
A Swift Popup Module help you popup your custom view easily

JFPopup JFPopup is a Swift Module help you popup your custom view easily. Support 3 way to popup, Drawer, Dialog and BottomSheet. Example To run the e

逸风 77 Dec 14, 2022
A Popover that mock iOS SkinTone Selection Popover.

IMessage SkinTone Popover This is a popover mock the iOS iMessage Skin Tone Selection Menu (Popover) Features Long press to invoeke the popover, and t

Vincent Liu 1 Dec 9, 2021
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
IntervalSlider is a slider library like ReutersTV app. written in pure swift.

IntervalSlider Description and appetize.io`s DEMO To run the example project, clone the repo, and run pod install from the Example directory first. Re

Nobuyasu 65 May 23, 2021
Example Catalyst app that is shown in a UIKit popover underneath an NSStatusItem

CatalystStatusItemPopoverExample Example Catalyst app that is shown in a UIKit popover underneath an NSStatusItem. References How to use macOS Specifi

Tom Irving 9 Sep 8, 2022
WhatsNext-Live - A small utility app for macOS showing upcoming calendar entries in a menubar popover

What's Next A small utility app for macOS using SwiftUI and EventKit to show you

Philipp 2 Jun 29, 2022
Droplet is a very small SwiftUI application that runs in the menubar and allows a file to be dropped onto the popover.

A Mac OS menubar application that allows drag-and-drop file uploading to an S3 bucket with a presigned URL copied to the clipboard. Work in progress.

Josh McArthur 11 Sep 8, 2022
It provides UI components such as popover, popup, dialog supporting iOS apps

Overview LCUIComponents is an on-going project, which supports creating transient views appearing above other content onscreen when a control is selec

Linh Chu 7 Apr 8, 2020