Easy to use PopOver in iOS
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example.xcodeproj [ISSUE-15] shouldDismissOnTap Bug fix Oct 12, 2018
Example Update to example Oct 12, 2018
KUIPopOver.xcodeproj switch to automatic provisioning Sep 27, 2018
KUIPopOver Merge branch 'release/1.1.1' Oct 12, 2018
Screenshot Update README.md Sep 4, 2017
.gitignore Initial commit Aug 31, 2017
.swift-version [ISSUE-13] Migration to Swift 4.2 Sep 27, 2018
.travis.yml Update travis.yml Sep 27, 2018
KUIPopOver.podspec 1.1.1 Release Oct 12, 2018
LICENSE Initial commit Aug 31, 2017
README.md - Update README Sep 27, 2018

README.md

KUIPopOver

Swift CocoaPods Carthage compatible

  • Easy to use PopOver in iOS (iPhone, iPad)

alt tag

Requirements

  • iOS 8.0+
  • Swift 4.2
  • Swift 4.0 (1.0.4)
  • Swift 3.0 (0.0.4)

Installation

CocoaPods

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

pod 'KUIPopOver'

Carthage

For iOS 8+ projects with Carthage

github "Kofktu/KUIPopOver"

Usage

Before

let popOverViewController = DefaultPopOverViewController()
popOverViewController.preferredContentSize = CGSize(width: 200.0, height: 300.0)
popOverViewController.popoverPresentationController?.sourceView = sender

let customView = CustomPopOverView(frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: 200.0, height: 300.0)))
popOverViewController.view.addSubview(customView)
popOverViewController.popoverPresentationController?.sourceRect = sender.bounds
present(popOverViewController, animated: true, completion: nil)

KUIPopOverUsable

public protocol KUIPopOverUsable {
    var contentSize: CGSize { get }
    var contentView: UIView { get }
    var popOverBackgroundColor: UIColor? { get }
    var arrowDirection: UIPopoverArrowDirection { get }
}

UIView

public func showPopover(sourceView: UIView, sourceRect: CGRect?, completion: ShowPopoverCompletion?)
public func showPopover(barButtonItem: UIBarButtonItem, completion: ShowPopoverCompletion?)
public func dismissPopover(animated: Bool, completion: DismissPopoverCompletion?)

UIViewController

public func showPopover(sourceView: UIView, sourceRect: CGRect?, completion: ShowPopoverCompletion?)
public func showPopover(withNavigationController sourceView: UIView, sourceRect: CGRect?, completion: ShowPopoverCompletion?)
public func showPopover(barButtonItem: UIBarButtonItem, completion: ShowPopoverCompletion?)
public func showPopover(withNavigationController barButtonItem: UIBarButtonItem, completion: ShowPopoverCompletion?)
public func dismissPopover(animated: Bool, completion: DismissPopoverCompletion?)

At a Glance

UIView

class CustomView: UIView, KUIPopOverUsable {
    // The default size is the size of the view, and you can override it if you want to customize it.
    var contentSize: CGSize {
    	return Size
    }
}

let view = CustomView()
view.showPopover(barButtonItem: sender)
view.dismissPopover(animated: true)
view.dismissPopover(animated: true, completion: {
})

UIViewController

class CustomViewController: UIViewController, KUIPopOverUsable {
    var contentSize: CGSize {
        // PopOver preferredContentSize
    }
}

let customViewController = CustomViewController()

// from senderView
customViewController.showPopover(sourceView: sender, sourceRect: sender.bounds)

// from barButtonItem
customViewController.showPopover(barButtonItem: sender)

// with NavigationController
customViewController.showPopover(withNavigationController: sender, sourceRect: sender.bounds)

customViewController.dismissPopover(animated: true)
customViewController.dismissPopover(animated: true, completion: {
})

Authors

Taeun Kim (kofktu), kofktu@gmail.com

License

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